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 = "
"; row = "
"; row = "
"; row = "
Full" n.amount "
"; row = "
" n.price "
"; row = "
"; $("#fittingProductList").append(row); }); $("#promotionArea").slideDown(); CalculateOrder(); }, error: function (xml) {
Many times when debugging, you will find that it jumps directly to error, and then jumps directly over. The success section is not executed. In fact, all the statements here are fine. The key to the problem is the return value. If the return value is wrong, it will not execute the success section. There are several situations where the return value is wrong:
1 .Format error. This is relatively simple. The more common ones are an extra comma: such as {"success":true,"list":[{},{},]} (an extra comma at the end) is not normal. There will be this, and it is easy to make mistakes when you use the for statement without processing the comma at the end.
2. Type error: This kind of error is the most difficult to find. If you are not sure, it is best to use characters. For example: "success": true is OK, "code": 0 is also OK. If it is "code": a123, there is a problem and a conversion error will occur. This is the correct way: "code": "a123"
Because jquery will ignore errors when debugging, it sometimes makes you crazy. A simple method is to write an error statement and add alert, and the error will be caught.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn