0
我想從MVC ajax調用PHP的休息webservice,但調用它後,它不會打電話成功,我不要在這裏失蹤。從ajax MVC asp.net調用PHP rest webservice?
Web服務需要2 PARAMATERS我的代碼
$.ajax({
type: "POST",
url: "https://test.com/custom/",
dataType: "json",
contentType: "application/json",
data: { "ReleaseVersion": "XXX", "ReleaseType":"XXX" },
success: function (data) {
alert("webservice called successfully");
}
})
它試圖用json.stringfy同時傳遞參數,但它不會工作。 是任何人如何解決這個問題。 環境:Visual Studio 2013和MVC 4.0。
添加'error:'函數,看看你是否有任何錯誤。 – ramiramilu
@ramiramilu錯誤:Readystate = 0,responcetext = undefined,status = 0,statustext = networkerror。如果'php service'和你的'website'都在兩個獨立的域中,那麼我得到了這個信息 – user26464
,那麼你需要允許'CORS'。你得到的錯誤是由於CORS或者由於'認證/授權'造成的。您是否能夠使用fiddler或任何其他工具發送請求和響應? – ramiramilu