Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在jQuery中不使用querystring向webservice发送数据_Jquery - Fatal编程技术网

在jQuery中不使用querystring向webservice发送数据

在jQuery中不使用querystring向webservice发送数据,jquery,Jquery,我使用以下jquery将一些数据发送到Web服务 var value1="This is val1"; var value2="This is val2"; $.ajax({ url: "Test.asmx/PostData", data: { data1: value1, data2: value2 }, success: function (html) { strReturn = html; }

我使用以下jquery将一些数据发送到Web服务

var value1="This is val1";
var value2="This is val2";

$.ajax({
                url: "Test.asmx/PostData",
                data: { data1: value1, data2: value2 },
                success: function (html) { strReturn = html; },
                async: false
            });
if (strReturn == "") {
//some error occured or the data did not get send to webservice
}
else
{
//The data is send to the webservice
}
现在的问题是,由于数据是作为查询字符串发布的。如果value1和value2中的数据长度很长,则不会将数据发送到Web服务

var value1="This is val1";
var value2="This is val2";

$.ajax({
                url: "Test.asmx/PostData",
                data: { data1: value1, data2: value2 },
                success: function (html) { strReturn = html; },
                async: false
            });
if (strReturn == "") {
//some error occured or the data did not get send to webservice
}
else
{
//The data is send to the webservice
}
如何避免使用querystring发送数据。我尝试将ajax参数“processData”设置为false,将“type”设置为POST,但仍然没有成功

如果有人能给我发送jquery代码,告诉我如何实现这一点,那就太好了


提前感谢

您不发送dat ais是什么意思?如果您这样做:

$.ajax({
                type: "POST",
                url: "Test.asmx/PostData",
                data: { data1: value1, data2: value2 },
                success: function (html) { strReturn = html; },
                async: false
            });
webservice根本没有收到任何数据?或者strReturn==“”?在第二种情况下,您是否声明strReturn以便可以看到它

var strReturn;
$.ajax({
                url: "Test.asmx/PostData",
                data: { data1: value1, data2: value2 },
                success: function (html) { strReturn = html; },
                async: false
            });

将类型设置为Post应该可以为您做到这一点。