开发者

Get Ajax GET request parameters on my aspx page

I am sending checkbox value from 1 ASP page to another.

I am using jQuery to make the Ajax request:

$.ajax({
    url: 'http:myurl.aspx',
    type: 'GET',
    data: dataToBeDeleted,
    succe开发者_Python百科ss: function () { alert('yay') },
    error: function () { alert("Data not deleted"); }
});

How do I get the values in myurl.aspx page? I tried with request.QueryString["data"] and request.QueryString["dataToBeDeleted"] but both gives no data.

Am I doing something incorrectly?


It all depends on the structure of your dataToBeDeleted parameter.

For example, if you have:

dataToBeDeleted = {"id1": "10", "id2": "20"};  //Object format

or

dataToBeDeleted = "id1=10&id2=20";  //String format

then you would read it in the server like this:

string id1 = Request.QueryString["id1"].ToString();
string id2 = Request.QueryString["id2"].ToString();

Hope this helps. Cheers


$.ajax({
            url: 'http:myurl.aspx?data=' + dataToBeDeleted,
            success: function () { alert('yay') },
            error: function () { alert("Data not deleted"); }
        });


The data should be passed in key, value format as

$.ajax({
            url: 'http:myurl.aspx',
            type: 'GET',
            data: 'key1=val1&key2=val2',
            success: function () { alert('yay') },
            error: function () { alert("Data not deleted"); }
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜