Here's a finished function:
Copy Code code as follows:
function Reloadpromotion () {
var A = parsefloat ($ ("#pNormalTotal"). HTML ()) + parsefloat ($ ("#pBarginTotal"). html ());
Jquery.ajax (
{
URL: "/ajax/orderredemption.aspx?vf=getlist",
Type: "POST",
DataType: "JSON",
DATA:{AMOUNT:A},
Success:function (JSON) {
$ ("#fittingProductList Tr.tableitem"). Remove ();
var data = json.list;
$.each (data, function (I, n) {
var id = n.pid;
var row = "<tr id=\" Trpromotin "+ ID +" \ "class=\" tableitem\ ">";
Row + = "<td><input id=\" Cbpromotionitem "+ ID +" \ "type=\" checkbox\ "value=\" "+ n.pid +" \ "Name=\" Promotionpro Duct\ "title=\" "+ N.price +" \ "Onclick=\" Calculateorder () \ "/></td>";
Row + + "<td><label for=\" Cbpromotionitem "+ ID +" \ ">" + n.pname + "</label></td>";
Row + + "<td> full" + N.amount + "</td>";
Row + + "<td>" + N.price + "</td>";
row = = "</tr>";
$ ("#fittingProductList"). append (row);
});
$ ("#promotionArea"). Slidedown ();
Calculateorder ();
},
Error:function (XML) {
Alert (arguments[1]);
var json = eval ("+ Xml.responsetext +"));
$ ("#promotionArea"). Slideup ();
}
});
}
A lot of times when you are debugging you will find that you jump directly to the error, and then jump straight past. The success segment was not executed. In fact, all the statements here are not a problem, the crux of the problem is the return value. If the return value fails, he does not perform the success segment.
1. The format is wrong. It's quite simple, it is more common to have a comma, such as: {"Success": True, "list": [{},{},]} (last more than one comma) normal does not have this, error prone when you use a For statement when the last did not deal with that comma.
2. Type error: This error is most difficult to find, it is best to use characters if you are not sure. For example: "Success": True is OK, "code": 0, also can. If it is "code": A123, there is a problem and there is a conversion error. To do this: "Code": "A123 "
Because it ignores errors during jquery debugging, it can be maddening sometimes. An easy way is to write an error statement, plus alert, where the error is captured.