window.MyCallback = function (data) {
console.log(data);
};
$(document).ready(function () {
$.ajax({
type: 'GET',
url: 'http://xxx.xxx.xxx.xx/MyService/Service.svc/MyMethod',
contentType: 'application/jsonp',
crossdomain: true,
dataType: "jsonp",
data: { 'username': 'Jack' },
crossDomain: true,
jsonpCallback: 'MyCallback',
success: function (txt) {
console.log(txt);
},
error: function (xhr, status, err) {
console.log(status, err);
}
});
});
我总是得到错误:MyCallback was not called.