var mall = {
MallID: $("#createId").val().trim(),
MallName: $("#createName").val().trim(),
HomeURL: $("#chomeurl").val().trim(),
PayNotifyURL: $("#cpayurl").val().trim(),
RefundNotifyURL: $("#crepayurl").val().trim(),
CompanyName: $("#createName").val().trim()
};
$.ajax({
type: "post",
url: "CreateMall",
data: { mallInstitution: JSON.stringify(mall) },
datatype: "json",
success: function (data) {
if (data.res == 1) {
alert ( "new success");
$("#hidenbkg").css({ "display": "none" });
$("#createmallshow").css({ "display": "none" });
} else if (data.res == 0) {
alert ( "MallID is:" + mallid + "business already exists, currently the largest merchant code is:" + data.Id);
} else if (data.res == 2) {
alert(data.msg);
};
}
});
Here is the record I am using ajax to send data to the background, do the corresponding business logic operations backstage after receiving the data; the great God is ignored, the spray would not have; if you have any good suggestions, we welcome the guidance, limited ability to express;
The above is a piece of JQuery code share with you use:
Js first build object is a mall, with the JSON.stringify (mall) converting the object into a string mall (JSON.stringfigy () method of the target sequence string js)
Then send the data back to the server using ajax (I used here is the C # MVC development model)
In using the data key value pairs ajax manner: mallInstitution: JSON.stringify (mall), so that when the server daemon interface, as long as the Request [ "mallInstitution"] can be received,
Background to the received data string, a pre-defined objects (MallInstitution) to deserialize, the corresponding data can be obtained; MallInstitution object property name must match Json target key; want you can get serializing data.
Here are some data controller receives the test code:
1 public JsonResult CreateMall() 2 { 3 var test = Request["mallInstitution"]; 4 var models = new JavaScriptSerializer().Deserialize<MallInstitution>(test); 5 6 //Business logic 7 8 9 JsonResult json = new JsonResult(); 10 return json; 11 }