为什么使用jQuery AJAX请求将回调参数添加到查询字符串 [英] why callback parameter is added to query string using jQuery AJAX request
本文介绍了为什么使用jQuery AJAX请求将回调参数添加到查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用MVC编写并发送jQuery AJAX请求.
我不明白为什么我在使用JQUERY发送AJAX请求时将"callback"参数添加到查询字符串中,如下所示
I write in MVC and send jQuery AJAX request.
I don''t understand why the ''callback'' parameter is added to query string when I send AJAX request using JQUERY as below
http://localhost:39224/Test/TAction/2?callback=jQuery151031896859929189747_1301556762907
返回响应时,这会导致错误,但我从未遇到过这样的问题.可以是什么?
这里的请求代码谢谢
This causes error when response is returned I have never encountered such a problem. What it can be?
here the request code Thank you
$.ajax({
type: ''POST'',
dataType: ''json'',
url: ''Test/TAction/'' + id,
async: false,
success: function (data, textStatus, XMLHttpRequest) {
var branches = $.parseJSON(data);
},
error: function (a, b, c) {
var d = 1;
}
});
推荐答案
.ajax({ 输入:"POST", dataType:``json'', 网址:"Test/TAction/" + ID, 异步:错误, 成功:函数(数据,textStatus,XMLHttpRequest){ var branchs =
.ajax({ type: ''POST'', dataType: ''json'', url: ''Test/TAction/'' + id, async: false, success: function (data, textStatus, XMLHttpRequest) { var branches =
.parseJSON(data); }, 错误:函数(a,b,c){ var d = 1; } });
.parseJSON(data); }, error: function (a, b, c) { var d = 1; } });
您是否尝试从通话中删除async: false
?
我认为您想对此进行异步调用,这也不会在地址栏中添加查询字符串.
玩得开心!
爱德华
Have you tried removinasync: false
from your call?
I think you want to make this a async call which will also not add the querystring in the addressbar.
Have fun!
Eduard
这篇关于为什么使用jQuery AJAX请求将回调参数添加到查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文