开发者

Sending data to webservice without using querystring in jQuery

I have the following jquery using which I send some data to a webservice.

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
}

Now the problem is that since the data is posted as query string. If the length of data in value1 &am开发者_开发百科p; value2 are very long, The data is not send to the webservice.

How can I avoid sending the data using querystring. I've tried setting the ajax parameters "processData" as false and "type" as POST but still no luck.

It would be great if anyone could send me the jquery code on how this can be done.

Thanks in advance


What do you mean that the dat ais not sent?If you do:

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

the webservice receives no data at all?or that strReturn == ""?In the second case did you declare strReturn so that it can be seen?

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜