开发者

What does 'dataString' for the field 'data' in jQuery's .ajax API?

For some reason it's not listed in the jQuery website where it's explaining the .ajax API and I just want to figure out what exactly 'dataString' is defining because it开发者_如何转开发's being used in a ajax script that I'm practicing with.


If your sending 'data' to a webservice or some page then that's what the data field is for. So for example if you want to insert a new user into a database via ajax your page that you're talking to you needs to know information.

For example:

 $.ajax({ url: "/ajax.asmx/addTo_Cart",
                        data: "{qty:" + qty + ",id:" + id + "}",
                        success: function (msg) {
                            var response = msg.d;
                            $("#ctl00_ShoppingCartMenu1_cartSum").html(response);
                        }
                    });

And the page being called:

 public string addTo_Cart(int qty, int id)
    {
     string doStuff ="lots of stuff done.";
     return doStuff;
}

This is .net but you should get the idea.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜