我想將對象存儲在寧靜的服務器中。我試着用HTML表單,一切工作正常,但使用JavaScript並不work.This是代碼ajax Post不起作用
var app2={"user_id" : seleVal, "name":nome2, "img":img2, "type":tipo2, "supplier_id": distro}
$.ajax({
type: "POST",
url: 'http://localhost:8000/products',
data: app2,
success: alert("success"),
error: alert("error"),
});
代碼進入成功和錯誤在同一時間,所以我試圖抓住使得功能的錯誤在他們裏面,但是當我這樣做,成功和錯誤似乎不responde.Thank你的幫助
隨着括號,兩者都被立即調用和他們的'return'值什麼是分配給'成功:'和'錯誤:'。相關:[JavaScript事件處理參數](http://stackoverflow.com/questions/3249128/javascript-event-handler-arguments) –