這個jQuery AJAX調用C#web方法這裏是我的JS:爲什麼不工作
function declassifyAjax(e) {
var items = getSelected();
var docIds = new Array();
items.each(get);
//get ids of QcItem/docId we are dealing with
function get(count, el) {
docIds[count] = $(el).parent().attr('id');
}
var dataObj = new Object();
dataObj.batchId = batchId;
dataObj.docIds = docIds;
var dataString = JSON.stringify(dataObj)
//make call to webservice to get html to recreate view showing
//pending declassification
$.ajax({
type: "POST",
url: applicationRoot + 'Models/BatchQC.asmx/declassify',
data: dataString,
contentType: "application/json; charset=utf-8",
success: function (data) {
if (ProcessWebMethodResult.processWebMethodResult(data) == true) {
declassifyProcess(data, e);
}
},
error: function (e) {
alert("Failed to Get declassification details");
}
});
}
這裏是我的Web服務:
//type to represent the input the declassify method
public class DeclassifyType
{
public int batchId;
public string[] docIds;
}
[WebMethod(EnableSession = true)]
public WebMethodResult declassify(DeclassifyType dataString)
{
}
任何和所有幫助表示讚賞!
Firebug中的調試顯示變量dataObj,batchId,docIds和dataString是正確的。我認爲我的Web方法簽名的設置方式有問題,因爲Ajax從未被解僱。逐句通過.ajax方法時,它會發生錯誤,而不是成功。
當你說「不工作」時,哪部分過程不起作用?你期望發生什麼?什麼錯誤信息,如果有的話,你會得到什麼?您是否嘗試過使用[Firebug](http://getfirebug.com/)或類似軟件進行調試?請編輯您的問題並提供更多詳細信息。 – 2010-10-21 09:57:48
'declassifyAjax'有沒有解僱?如果你在裏面放置一個alert()會發生什麼? – 2010-10-21 10:06:06