jQuery的阿贾克斯获得例如 [英] jquery ajax get example

查看:150
本文介绍了jQuery的阿贾克斯获得例如的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我使用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??

有人可以告诉我一个jQuery GET例如直接调用Web服务的一个WebMethod?

Can somebody show me a jquery GET example calling a webmethod of a web service directly?

更新:使用异步标志的建议如下真的是所有我需要做的所以这对我的作品。我还是好奇,需要做的code以上,使之成为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的阿贾克斯获得例如的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆