简体   繁体   中英

SyntaxError: Unexpected token < in JSON at position 8

Dears, I got error when i call the ajax function.

SyntaxError: Unexpected token < in JSON at position 8
    at JSON.parse (<anonymous>)
    at parseJSON (jquery?v=M6dmVkrHVhoZ1gfOtvVDZbgBcQTsbWxoLsRizcGkbPk1:1)
    at vo (jquery?v=M6dmVkrHVhoZ1gfOtvVDZbgBcQTsbWxoLsRizcGkbPk1:1)
    at k (jquery?v=M6dmVkrHVhoZ1gfOtvVDZbgBcQTsbWxoLsRizcGkbPk1:1)
    at XMLHttpRequest.u (jquery?v=M6dmVkrHVhoZ1gfOtvVDZbgBcQTsbWxoLsRizcGkbPk1:1)

This is my ajax call code:

   function MyFunction() {

    $.get("/Base/TestMethod", { message: 'nice' }, function (data) {

        console.log(data);

    }, 'json').fail(function (jqXhr, textStatus, errorThrown) {
        alert(textStatus + ": " + errorThrown + ": " + jqXhr.responseText);
        console.log(errorThrown);
    });
}

In my case, the returned JSON was too big. Try set MaxJsonLength to max int value.

var jsonResult = Json(obj, JsonRequestBehavior.AllowGet);
jsonResult.MaxJsonLength = int.MaxValue;
return jsonResult;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM