当代码放在Javascript文件中时,Ajax Json代码不起作用。 [英] Ajax Json code is not working when the code is placed in Javascript file.
问题描述
亲爱的专家,
我对Asp.net有疑问。在我的Asp.net项目中,我使用ajax json代码通过webmethod将值传递给webservice。
当我在webform中编写ajax代码时,它是工作正常。当我在javascript文件中移动此代码时,它无法正常工作......
有人可以帮我解决这个问题...这是下面使用的ajax代码。
Dear Experts,
I have a doubt in Asp.net. In my Asp.net project i have used a ajax json code for passing values to webservice through webmethod.
When i write the ajax code in the webform, then it is working fine. And when i moved this code in a javascript file, then it is not working......
Can someone please help me to solve this issue.... Here is the below ajax code that am used.
$.ajax(
{
type: "POST",
url: "../General_Services.asmx/HelloWorld",
dataType: "json",
data: JSON.stringify({ "Sub_Item_ID": "abc" }),
contentType: "application/json; charset=utf-8",
success: function (json) {
alert(json.d);
}
});
先谢谢,
Dileep
Thanks in Advance,
Dileep
推荐答案
.ajax(
{
type: POST,
url: ../ General_Services.asmx / HelloWorld,
dataType: json,
数据: JSON .stringify({ Sub_Item_ID: abc}),
contentType:< span class =code-string> application / json; charset = utf-8,
成功: function (json){
alert(json.d);
}
});
.ajax( { type: "POST", url: "../General_Services.asmx/HelloWorld", dataType: "json", data: JSON.stringify({ "Sub_Item_ID": "abc" }), contentType: "application/json; charset=utf-8", success: function (json) { alert(json.d); } });
先谢谢,
Dileep
Thanks in Advance,
Dileep
这篇关于当代码放在Javascript文件中时,Ajax Json代码不起作用。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!