mvc 简单的前端ajax请求,后端方法获取参数方法

$.ajax({
    type:"post"
    url:"/text/funtext/1"     ///这是默认路由  {controller}/{action}/{id}
    success:function(data){
        //回传的数据
    }
})
//对应方法获取参数
【httppost】
public  string   funtext(string id)
{
  //id就是1
}

-------------------------------------------------------------------------------
$.ajax({
    type:"post"
    url:"/text/funtext"     ///这是mvc路由  {controller}/{action}
    data:{'name':'这是测试'}
    success:function(data){
        //回传的数据
    }
})
//对应方法获取参数
【httppost】
public  string   funtext(string name)
{
  //name就是 “这是测试”
}
//或者
【httppost】
public  string   funtext()
{
  //Request.From可以获取页面传递的所有参数
  //Request["name"].ToString();
}
//当然还有其他方法 就不一一说

 

posted @ 2019-03-12 16:03  LIGHTPRO  阅读(1767)  评论(0编辑  收藏  举报