我有一個asp.net Web服務,我想通過Jquery Ajax調用,但執行我得到500 Internal Server Error
和響應我得到{"Message":"Invalid JSON primitive: Name.","StackTrace":"
看到在瀏覽器開發工具的輸出(螢火蟲)。 這裏是我的web服務代碼..問題通過jQuery的Ajax調用WebService
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class DateWebService : System.Web.Services.WebService {
HttpRequest request;
public DateWebService() {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public string GetData(string name, string contact, string email) {
string Name = request[name];
string Contact = request[contact];
string Email = request[email];
return Name+Contact+Email;
}
}
這裏是我的jQuery Ajax代碼..
$(document).ready(function(){
$("#Button1").click(function() {
$.ajax({
type: "POST",
url: "/ASPNET_WebServices_JQuery/DateWebService.asmx/GetData",
data: { 'Name': 'SRI', 'Contact': '787979879898', 'Email': '[email protected]' },
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg)
{
$("#output").text(msg.d);
}
});
});
});
請幫我解決這個issue..Thanks ...
它不工作在所有。 – 2014-11-24 12:12:32
檢查已編輯的答案.... – 2014-11-24 12:17:48
'未知的網絡方法GetData'錯誤放在'靜態' – 2014-11-24 12:23:06