我有以下的Web服務; [WebMethod]
public string HelloWorld()
{
return "Hello World";
}這是存貨標準,沒有改動的等級裝飾師。我有這個jQuery方法;var webMethod = "http://localhost:54473/Service1.asmx/HelloWorld"; $.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
data: "{}",
dataType: "json",
url: webMethod,
success: function(msg){ alert(msg.d); },
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(errorThrown);
}});這是一個POST操作,因為稍后我需要將數據發布到它。當我執行jQuery時,我會得到一個“No Transfer”錯誤返回。我還應該提到的一點是,jQuery存儲在我的機器上的一個簡單的HTML文件中,WebService也運行在我的機器上。HTML頁面上沒有代碼,它只是一個網頁,而不是一個c#項目或任何東西。誰能給我指出正確的方向嗎?
3 回答

慕容森
TA貢獻1853條經驗 獲得超18個贊
jQuery.support.cors = true;
- 3 回答
- 0 關注
- 451 瀏覽
添加回答
舉報
0/150
提交
取消