jquery ajax获取示例 [英] jquery ajax get example
问题描述
目前我正在使用这样的 post 方法
At the moment I'm using the post method like this
$.ajax({
type: "POST",
url: "Servicename.asmx/DoSomeCalculation",
data: "{param1ID:"+ param1Val+"}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
UseReturnedData(msg.d);
},
error: function(err) {
alert(err.toString());
if (err.status == 200) {
ParseResult(err);
}
else { alert('Error:' + err.responseText + ' Status: ' + err.status); }
}
});
我是否认为如果我使用 GET 请求而不是 POST 行为将更改为同步请求,即执行将等到从服务器收到响应??
Am I correct in believing that if I use a GET request instead of POST the behavior will change to being a synchronous request i.e. the execution will wait until the response has been received from the server??
有人可以向我展示一个直接调用 Web 服务的 webmethod 的 jquery GET 示例吗?
Can somebody show me a jquery GET example calling a webmethod of a web service directly?
更新:使用下面建议的异步标志真的是我需要做的一切,这对我有用.我仍然很好奇需要对上面的代码做哪些工作才能使其成为 GET 请求.更改类型:GET"没有达到预期的效果!
UPDATE: Using the async flag as suggested below is really all i needed to do so this works for me. I'm still curious as to what work needs to be done to the code above to make it a GET request. Changing type: "GET" doesn't have the desired effect!
推荐答案
您可以决定是否希望 ajax 调用异步或不使用:
You can decide if you want the ajax call to be async or not using this:
$.ajax({
async: false/true,
//more options
});
这篇关于jquery ajax获取示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!