'[{"imgPath": "C","price": "B","specDesc": "C"},{"imgPath": "D","price": "E","specDesc ": "F"}]' This is a parameter for an ajax request. How do I get the data on the page and create it in a loop to form a json? How should I do it? Please answer me! ! !
This is the page
滿天的星座2017-05-19 10:45:06
Press the control to take out the value, form an object literal, and then format it into JSON... To determine what kind of data is generated, you need to know how the interface is agreed upon.
Making a pair should be simple, like
var aModel = {
imgPath: $("#imgPath").val(),
price: $("#price").val()
}
Generating JSON is just one sentence
var json = JSON.stringify(aModel)
仅有的幸福2017-05-19 10:45:06
var arr = [];
var param = {}
$("块").each(funciton(){
var _temp = {"imgPath": "C","price": "B","specDesc": "C"};
arr.push(_temp)
})
param.resutl=arr;