Ajax调用不起作用。任何人都可以帮助我...... [英] Ajax calling is not working. Any one may help me...
问题描述
在asp.net页面上我使用的代码如下:
$(' 。del')。click( function (event){
var parentID = { CategoryID :$( this )。nearest(' li').attr(' id')};
parentID = JSON .stringify(parentID);
alert(' 在ajax调用'之前);
$ .ajax({
类型: POST,
url: MasterService.asmx / RemoveCategory,
data:parentID,
contentType: application / json; charset = utf-8,
dataType: json,
成功: function (msg){
alert(' hurray!Success。' + msg.d); $( this )。nearest(' li')。remove();
},
失败:功能(响应){
alert(response.d);
}
});
});
并制作了一个网络服务方法:
[WebMethod]
public string RemoveCategory( string CategoryID)
{
CategoryMasterBAL categorymasterBAL = new CategoryMasterBAL();
return categorymasterBAL.RemoveCategory(CategoryID);
}
但是当我在$ .ajax之前运行这个应用程序时({alert被解雇但没有成功或错误触发,调试控制没有转到C#代码
(' 。del')。click( function (event){
var parentID = { CategoryID:
< blockquote>( this )。nearest(' li').attr(' id')};
parentID = JSON .stringify(parentID);
alert(' 在ajax调用'之前);
on asp.net page i am using the code like this: 这篇关于Ajax调用不起作用。任何人都可以帮助我......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
type: POST,
url: MasterService.asmx / RemoveCategory,
data:parentID,
contentType: application / json; charset = utf-8,
dataType: json,
成功: function (msg){
alert(' hurray!Success。' + msg.d);
$('.del').click(function (event) {
var parentID = { "CategoryID": $(this).closest('li').attr('id') };
parentID = JSON.stringify(parentID);
alert('before ajax calling');
$.ajax({
type: "POST",
url: "MasterService.asmx/RemoveCategory",
data: parentID,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
alert('hurray! Success. ' + msg.d); $(this).closest('li').remove();
},
failure: function (response) {
alert(response.d);
}
});
});
and made a web service method as:
[WebMethod]
public string RemoveCategory(string CategoryID)
{
CategoryMasterBAL categorymasterBAL = new CategoryMasterBAL();
return categorymasterBAL.RemoveCategory(CategoryID);
}
but when i run this application then before $.ajax({ alert is fired but not fired in success or error and on debugging control not going to C# code('.del').click(function (event) {
var parentID = { "CategoryID":
(this).closest('li').attr('id') };
parentID = JSON.stringify(parentID);
alert('before ajax calling');
.ajax({
type: "POST",
url: "MasterService.asmx/RemoveCategory",
data: parentID,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
alert('hurray! Success. ' + msg.d);