Js
$ (function () {
$.ajax ({
URL: "http://localhost:1266/test/t",
Data: {"A": 1, "B": 2, "C": 3},
DataType: "Jsonp",
JSONP: "Callback",//jquery the name of the generated validation parameter
timeout:3000,
Crossdomain:true,
Error:function (A, B, c) {
if ("timeout" = = c) {
Alert ("Timeout");
} else {
Console.log (c);
}
},
Success:function (JSON) {
Alert (json.code+ ", a=" +json.a);
}
});
});
Html:
@{
Viewbag.title = "Test Page";
}
<script src= "~/scripts/jquery-1.8.2.min.js" ></script>
<body>
Hey, heh.
</body>
<script src= "~/comtent/js/dataup.js" ></script>
Controller
public class Testcontroller:basecontroller
{
//<summary>
//cross-domain testing
//</summary>
//< Returns></returns>
public actionresult T ()
{
var a = Request["a"];
var b = request["a"];
var c = request["a"];
return Content (request["callback"] + "(" + Jsonconvert.serializeobject (New {code = 0, a = a, B = b, c = c}) + ")";
}}
C # MVC implements Ajax across domains