IIS的请求.表单和JavaScript XMLHTTPRequest不工作在Firefox和Chrome
IIS Request.Form and JavaScript XMLHTTPRequest not working in Firefox and Chrome
我使用XMLHttpRequest发送FormData到IIS服务器。在服务器端,请求。当浏览器是IE时,表单对象具有表单数据,但当浏览器是FireFox或Chrome时,它没有表单数据。下面的示例使用FormData对象向服务器提交表单。在IE中,Request.Form.Count是1。而火狐和Chrome则是零。在所有情况下,我都希望结果是1。我想我做错了什么,但我没有发现。
下面是客户端代码:
<script>
function SubmitForm() {
var http = new XMLHttpRequest()
var data = new FormData()
data.append("Text1", document.getElementById("Text1").textContent);
http.open("POST", "ajaxtest.aspx", true);
http.setRequestHeader("Content-Type", "multipart/form-data");
http.onreadystatechange = function () {
if (http.readyState == 4 && http.status == 200) {
alert(http.responseText);
}
}
http.send(data);
}
</script>
<body>
<input id="Text1" type="text" value="This is text to the server" />
<input id="Button1" type="button" value="button" onclick="SubmitForm()" />
</body>
服务器代码:
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Request.HttpMethod = "POST" Then
Response.Write("Request.Form.Count=" & Request.Form.Count)
Response.End()
End If
End Sub
原来问题是setRequestHeader。我删除了它,得到了想要的效果
相关文章:
- 为什么这在IE中的工作方式与在Firefox中不同
- JS可以在Chrome中工作,但不能在Firefox中工作
- Facebook登录按钮没有'不能在Firefox上工作
- JS在firefox中无法正常工作
- firefox插件:退出不工作的应用程序观察器
- :focus:一起活跃,不在firefox上工作
- 加载Soundcloud嵌入式播放器OnClick在FireFox中不工作
- javascript()onclick隐藏元素-dos'我不在firefox工作
- 异步加载的SVG过滤器feColorMatrix在Chrome中工作,而不是在Safari或Firefox中
- Iframe加载调整大小在Chrome中工作,但不能在IE或Firefox中工作
- 按钮处于活动状态,焦点无法在Mac FireFox上工作
- HTML5 Canvas undo是'在IE或Firefox中无法正常工作
- javascript代码,用于删除firefox中的空白,但在IE和chrome中无法正常工作
- JavaScript 在 Chrome 中工作,而不是在 Firefox 中
- jQuery代码在Firefox中工作,但在IE中失败
- Javascript加载功能只能在一半的时间内工作(Firefox)
- jQuery点击不工作FireFox -可能是event.preventdefault
- JQUERY .load不能与窗口一起工作.firefox中的位置
- Javascript菜单不工作Firefox
- Jquery只在我重新加载页面时工作-Firefox