首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >.Net HttpListenerRequest响应在chrome中不使用Ajax。

.Net HttpListenerRequest响应在chrome中不使用Ajax。
EN

Stack Overflow用户
提问于 2013-10-30 02:08:14
回答 1查看 274关注 0票数 0

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

代码语言:javascript
复制
                        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();

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

代码语言:javascript
复制
xmlhttp.open("POST", "", false);
var command = new commandObject();
command.command = "xml";
try {
  xmlhttp.send(JSON.stringify(command));
} catch(e){
  alert(e);
}

我一直在犯这个错误:

代码语言:javascript
复制
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中工作。我希望铬能给出更多的细节。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-10-30 16:41:45

在对代码进行重新编码并使用异步ajax调用之后,chrome似乎可以工作。我猜同步Ajax在chrome上坏了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19672588

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档