0
這裏是我的jQuery:HTTPGET失敗
$.ajax({
type: 'GET',
url: '/services/Service.asmx/FamilyHistory',
data: JSON.stringify({
userID: 10,
historyID: famid
}),
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function(val) {
var famHist = val.d;
alert(famHist.ID);
},
error: function() {
parent.$.jGrowl('<b>Failed</b>',
{
header: 'User Action:',
life: 3000
});
}
});
我的班級:
public sealed class FamilyHistoryEntity
{
public string ID { get; set; }
public string RelativeName { get; set; }
}
我的Web服務:
[WebMethod(EnableSession = true)]
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true)]
public FamilyHistoryEntity FamilyHistory(int userID, string historyID)
{
return GetFamilyHistory(historyID, userID); // returns a FamilyHistoryEntity class
}
問題是,我甚至不能讓它在web服務上做一個斷點,它只會引發錯誤的jquery ajax事件。
我們需要對json進行字符串化以將參數傳遞給asp.net webservice。 – 2010-08-02 09:24:04
@Martin好的。那麼我們確定famid是一個字符串變量而不是int嗎? – spinon 2010-08-02 09:29:05
確定數據部分工作,它通過web服務。但是當它返回值時,jquery拋出一個錯誤事件。我需要[序列化] C#類嗎? – 2010-08-02 09:30:33