Back to Catalog
Something to say.
This is a very interesting topic, in Ko, there are objects and arrays of objects two, but both of these objects are a function of external performance, if you want to get his value, you need to make a functional call, such as Ko_a (), its result is a specific value or array or function, and ko_ A represents a Ko object.
Today, I would like to talk about how to pass objects and arrays to the background in the Ajax method, in general, we pass strings and numbers for the background, and if we want to pass the object, we need to use the $.param method, the following specific code to say.
Something to do.
Generally after the code ideal is like this
Public Jsonresult generatororder (int[] idarr)//Some shopping cart record ID that needs to be generated order { // Todo:generator Order return Json (Idarr); }
And such a background interface, our front-end Ajax parameters need to do a $.param processing, as follows
$.ajax ({type:"Post", URL:"/order/generatororder", Data: $.param (self. Selcart (),true),//It is not possible to use the array directly as a $.param parameter .DataType:"JSON", Success:function (data) {Boxy.alert ("To Paypage of products :"+json.stringify (data)); } });
In fact, the above code run the result is wrong, because the $.param method only supports the object, does not support the direct array, and the array if it can be supported in the object, it is also interesting, so the above code we need to modify
$.ajax ({type:"Post", URL:"/order/generatororder", Data: $.param ({idarr:self. Selcart ()},true),//! Note to pass the second argumentDataType:"JSON", Success:function (data) {Boxy.alert ("To Paypage of products :"+json.stringify (data)); } });
The following run results are what we want to see
Back to Catalog