我是 ajax 新手,但我没有低估错误我有这个代码:
function text_ajax(){
$('.purchase-btn').click(function() {
var JSONObject= {
"prod_name": $('.soc-name span').text(),
"prod_quantity": $('.soc-amount span').text(),
"prod_price": $('.soc-price span').text(),
"prod_line_price": $('.soc-total span').text(),
"prod_shipment_price":$('.soc-shipping-fee span').text(),
"prod_vat": $('.soc-vat-fee span').text(),
"prod_total_price": $('.soc-total-sum').text(),
};
$.ajax({
type: "POST",
dataType: "json",
url: "/soda/checkout/ajax_post",
data: {myData: JSON.stringify(JSONObject)},
success: function(){
alert('Items added');
},
error: function(e){
alert(e.message);
}
});
});
}
我得到了所有的元素,但仍然出现错误,有人能帮忙吗?