开发者

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

开发者 https://www.devze.com 2023-02-09 23:15 出处:网络
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 u

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

精彩评论

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