0

在我的代码中,我正在执行以下操作:

                        response.ContentType = "text/xml";
                        StringWriter stringToWrite = new StringWriter();

                        respose_example = getData();


                        System.Xml.Serialization.XmlSerializer outSeralizeList = new System.Xml.Serialization.XmlSerializer(typeof(List<Registers>));
                        outSeralizeList.Serialize(stringToWrite, respose_example);
                        string responseString = stringToWrite.ToString();

                        // Construct a response.
                        response.ContentEncoding = System.Text.Encoding.UTF8;
                        byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
                        // Get a response stream and write the response to it.
                        response.ContentLength64 = buffer.Length;
                        Stream output = response.OutputStream;

                        output.Write(buffer, 0, buffer.Length);

                        // You must close the output stream.
                        output.Close();

在我的浏览器代码中,我正在执行以下操作:

xmlhttp.open("POST", "", false);
var command = new commandObject();
command.command = "xml";
try {
  xmlhttp.send(JSON.stringify(command));
} catch(e){
  alert(e);
}

我不断收到此错误:

DOMException {message: "A network error occurred.", name: "NetworkError", code: 19, stack: "Error: A network error occurred.↵    at getXML (ht…rElement.onclick (http://127.0.0.1:7000/:403:164)", INDEX_SIZE_ERR: 1…}
code: 19
message: "A network error occurred."
name: "NetworkError"
stack: "Error: A network error occurred.↵    at getXML (http://127.0.0.1:7000/:84:19)↵    at create_table (http://127.0.0.1:7000/:182:22)↵    at HTMLAnchorElement.onclick (http://127.0.0.1:7000/:403:164)"
__proto__: DOMException

不知道为什么它在 FF 中有效。我希望chrome能提供更多细节。

4

1 回答 1

0

在重新编码我的代码并使用异步 ajax 调用 chrome 之后似乎工作。我猜同步 Ajax 在 chrome 上被破坏了。

于 2013-10-30T16:41:45.870 回答