【发布时间】:2014-06-13 13:41:41
【问题描述】:
我正在阅读有关此的几篇文章,并对我的代码进行了一些更改,但没有运气。
任何人都可以调查一下,看看这里发生了什么?或者也许是另一种方式来做我需要的事情(使用 ziptastic 通过邮政编码检索城市、州)
代码在 Chrome 中运行良好 (http://jsfiddle.net/7VtHc/117/)
html
<asp:TextBox ID="txtZipCode" runat="server"></asp:TextBox>
<asp:TextBox ID="txtCity" runat="server"></asp:TextBox>
<asp:TextBox ID="txtState" runat="server"></asp:TextBox>
脚本
<script src="http://code.jquery.com/jquery-1.10.2.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$("input[id$='txtZipCode']").keyup(function () {
var el = $(this);
if (el.val().length === 5) {
$.ajax({
url: "http://zip.getziptastic.com/v2/US/" + el.val(),
cache: false,
dataType: "json",
type: "GET",
success: function (result, success) {
$("input[id$='txtCity']").val(result.city);
$("input[id$='txtState']").val(result.state);
}
});
}
});
});
</script>
谢谢,
【问题讨论】:
-
您可以查看此页面并使用
XMLHttpRequest():javascriptkit.com/jsref/ajax.shtml -
您不能告诉您在 IE8 中遇到了什么错误,而是...?
-
你应该在IE中使用Xdomain请求来实现跨域ajax
-
@A.Wolff 在 IE8 中什么也没有发生,什么都没有 :(
标签: javascript jquery asp.net ajax internet-explorer-8