Ajax call with jQuery in ASP.NET MVC does not pass parameters

Posted by desmati on Stack Overflow See other posts from Stack Overflow or by desmati
Published on 2010-05-07T01:37:57Z Indexed on 2010/05/07 1:58 UTC
Read the original article Hit count: 433

Filed under:
|
|
|

The Route is:

routes.MapRoute(
    "Ajax", // Route name
    "BizTalk/Services/{action}", // URL with parameters
    new
    { // Parameter defaults
     controller = "BizTalk"
    }
   );

My Controller is:

public JsonResult AjaxTest(string s, int i, bool b)
  {
   return Json("S: " + s + "," + "I: " + i + "," + "B: " + b);
  }

My jQuery Code:

$(document).ready(function() {
   $("#btn_test").click(function() {
    var s = "test";
    var i = 8;
    var b = true;
    $.ajax({
     type: "POST", cache: false,
     url: "/BizTalk/Services/AjaxTest",
     data: { i: i, s: s, b: b },
     contentType: "application/json; charset=utf-8",
     dataType: "json",
     success: function(msg) {
     }
    });
   });
  });

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about jQuery