2016-03-22 290 views
1

我試圖使用jQuery發送Ajax的POST請求,但我得到400(錯誤請求)錯誤 這裏是我的代碼:入門jQuery的AJAX POST 400(錯誤請求)錯誤

$.ajax({ 
     url: "http://192.168.3.118:2244/api/Customer/PostTblCustomer", 
     type: "POST", 
    data: {"CustName":"naveen", 
    "Mobile": 9490429799, 
    "Email":"[email protected]", 
    "Address":"Hyderabad", 
    "Password":12345, 
    "PinCode": 50000, 
    "IsServiceProvider":"false", 
    "Is_Blocked":"false"}, 

    dataType: "json", 
    contentType:"application/json", 

    success: function(data){ 
     alert("success"); 
     alert(data); 
     console.log(data); 
    }, 
    error: function (xhr, ajaxOptions, thrownError) { 
     alert(xhr.status); 
     alert("error"); 
     alert(thrownError); 

     console.log(xhr.status) 
     console.log(thrownError); 
     console.log(ajaxOptions); 
    } 
}) 

我新手機的差距歡迎指正在adavance

+0

呼叫可與郵遞員或其他Ajax工具附代碼謝謝上面?該錯誤是在真實設備還是模擬器/瀏覽器中顯示的? – Del

回答

0

您可能需要字符串化數據

data: JSON.stringify({"CustName":"naveen", 
    "Mobile": 9490429799, 
    "Email":"[email protected]", 
    "Address":"Hyderabad", 
    "Password":12345, 
    "PinCode": 50000, 
    "IsServiceProvider":"false", 
    "Is_Blocked":"false"}), 
+0

謝謝你的回覆我收到錯誤作爲郵政http://192.168.3.118:2244/api/Customer/PostTblCustomer 500(內部服務器錯誤) –

+0

@NaveenDodda您的192.168.3.118:2244/api/Customer/PostTblCustomer頁面包含錯誤 –