我想知道是否可以将 JSON 格式的 ascii 控制代码从经典 ASP 返回到 jQuery ajax 调用。
这是我的 jQuery 调用:
$.ajax({
url: "/jsontest.asp",
type: "POST",
cache: false,
dataType: "json",
complete: function(data)
{
var o = $.parseJSON(data.responseText.toString());
},
error: function(data1, data2)
{
alert("There has been an error - please try again");
}
});
这是我的调用页面:
{"val1":123,"val2":"abcdef"}
以上工作正常,但如果我将调用页面更改为包含 ascii 字符 31 (1F),如下所示:
{"val1":123,"val2","abc\x1Fdef"}
然后我在我的错误函数中收到警报。可以这样做吗,如果可以,请问如何。
注意:我使用的是 jQuery 1.7.1 以及 IIS 6 和 IIS 7
我尝试过:\x1f、%1f 和 \u001f
查看 data1 和 data2 中的值。
data2 有字符串“parsererror”
data1 是具有以下属性的对象:
readyState: 4
setRequestHeader: function (a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this}
getAllResponseHeaders: function (){return s===2?n:null}
getResponseHeader: function (a){var c;if(s===2){if(!o){o={};while(c=bH.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c}
overrideMimeType: function (a){s||(d.mimeType=a);return this}
abort: function (a){a=a||"abort",p&&p.abort(a),w(0,a);return this}
done: function (){if(c){var a=c.length;m(arguments),i?k=c.length:e&&e!==!0&&(j=a,n(e[0],e[1]))}return this}
fail: function (){if(c){var a=c.length;m(arguments),i?k=c.length:e&&e!==!0&&(j=a,n(e[0],e[1]))}return this}
progress: function (){if(c){var a=c.length;m(arguments),i?k=c.length:e&&e!==!0&&(j=a,n(e[0],e[1]))}return this}
state: function (){return e}
isResolved: function (){return!!e}
isRejected: function (){return!!e}
then: function (a,b,c){i.done(a).fail(b).progress(c);return this}
always: function (){i.done.apply(i,arguments).fail.apply(i,arguments);return this}
pipe: function (a,b,c){return f.Deferred(function(d){f.each({done:[a,"resolve"],fail:[b,"reject"],progress:[c,"notify"]},function(a,b){var c=b[0],e=b[1],g;f.isFunction(c)?i[a](function(){g=c.apply(this,arguments),g&&f.isFunction(g.promise)?g.promise().then(d.resolve,d.reject,d.notify):d[e+"With"](this===i?d:this,[g])}):i[a](d[e])})}).promise()}
promise: function (a){if(a==null)a=h;else for(var b in h)a[b]=h[b];return a}
success: function (){if(c){var a=c.length;m(arguments),i?k=c.length:e&&e!==!0&&(j=a,n(e[0],e[1]))}return this}
error: function (){if(c){var a=c.length;m(arguments),i?k=c.length:e&&e!==!0&&(j=a,n(e[0],e[1]))}return this}
complete: function (){if(c){var a=c.length;m(arguments),i?k=c.length:e&&e!==!0&&(j=a,n(e[0],e[1]))}return this}
statusCode: function (a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this}
responseText: {"val1":123,"val2":"abcdef"}
status: 200
statusText: OK