jquery ajax 200 OK JSON.ParseError

5 jquery webmethod

我有一个控件,它有一个文本框,当它的内容发生变化时,会使这个javascript函数变得棘手:

page参数是document.URL因为控件没有附加.asxc页面,并且fieldValue是文本框的值.

function UpdateFieldsOnListSelection(page, fieldValue) {
    $.ajax({
        type: "POST",
        url: page + "/IsSelectedListPictureLibrary",
        data: { "libraryInfo": fieldValue },
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (data) {
            alert("Success!");
        },
        error: function (jqXHR, textStatus, errorThrown) {
            alert("jqXHR: " + jqXHR.status + "\ntextStatus: " + textStatus + "\nerrorThrown: " + errorThrown);
        }
    });
};
Run Code Online (Sandbox Code Playgroud)

它不断抛出这个错误:

jqXHR:200
textStatus:parsererror
errorThrown:SyntaxError:JSON.parse:意外字符

代码IsSelectedListPictureLibrary:

[WebMethod]
public static bool IsSelectedListPictureLibrary(string libraryInfo)
{
    if (string.IsNullOrEmpty(libraryInfo)) return false;

    var common = new Utility();
    var storedLibraryInfo = common.GetStoredLibraryInfo(libraryInfo);

    if (storedLibraryInfo == null) return false;

    var web = SPContext.Current.Site.OpenWeb(storedLibraryInfo.WebId);
    var spList = web.Lists[storedLibraryInfo.LibraryId];

    if (spList.BaseTemplate == SPListTemplateType.PictureLibrary)
    {
        web.Dispose();
        return true;
    }

    web.Dispose();
    return false;
}
Run Code Online (Sandbox Code Playgroud)

我试过更改jsonajax jsonp,但发生了同样的错误.
我试过改变格式data.

有任何想法吗?

Cat*_*lin 20

尝试从Ajax参数中删除contentTypedataType自动识别它们