相关疑难解决方法(0)

Ajax处理中的"无效的JSON原语"

我在jQuery的ajax调用中遇到错误.

这是我的jQuery函数:

function DeleteItem(RecordId, UId, XmlName, ItemType, UserProfileId) {
    var obj = {
        RecordId: RecordId,
        UserId: UId,
        UserProfileId: UserProfileId,
        ItemType: ItemType,
        FileName: XmlName
    };
    var json = Sys.Serialization.JavaScriptSerializer.serialize(obj);

    $.ajax({
        type: "POST",
        url: "EditUserProfile.aspx/DeleteRecord",
        data: json,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        async: true,
        cache: false,
        success: function(msg) {
            if (msg.d != null) {
                RefreshData(ItemType, msg.d);
            }
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            alert("error occured during deleting");
        }
    });
}
Run Code Online (Sandbox Code Playgroud)

这是我的WebMethod:

[WebMethod]
public static string DeleteRecord(Int64 RecordId, Int64 UserId, Int64 …
Run Code Online (Sandbox Code Playgroud)

c# jquery webmethod

92
推荐指数
6
解决办法
23万
查看次数

标签 统计

c# ×1

jquery ×1

webmethod ×1