Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 尝试使用zipstatic,但未得到响应_Javascript_Jquery - Fatal编程技术网

Javascript 尝试使用zipstatic,但未得到响应

Javascript 尝试使用zipstatic,但未得到响应,javascript,jquery,Javascript,Jquery,我尝试使用jQuery。我的代码如下。但我没有得到任何回应。我错过什么了吗 jQuery(function() { jQuery("#form").hide(); jQuery("#postcode").keyup(function() { var country = jQuery("#country"); var postcode = jQuery(this); jQuery.ajax({ url: "http://zip.eleven

我尝试使用jQuery。我的代码如下。但我没有得到任何回应。我错过什么了吗

jQuery(function() {

  jQuery("#form").hide();
  jQuery("#postcode").keyup(function() {

    var country = jQuery("#country");
    var postcode = jQuery(this);

      jQuery.ajax({
        url: "http://zip.elevenbasetwo.com/v2/" + country.val() + "/" + postcode.val(),
        cache: false,
        dataType: "json",
        type: "GET",
        success: function(result, success) {
          jQuery("#city").val(result.city);
          jQuery("#state").val(result.state);
          jQuery("#form").slideDown();
          jQuery("#postcode").blur();
          jQuery("#country").blur();
          jQuery("#address1").show().focus();

        },
        error: function(result, success) {
          jQuery(".zip-error").slideDown(300);
        }
      });
  });
});

如果我只是从浏览器中输入,那么我就会得到响应。我只需要在url中输入两个变量,国家和邮政编码就可以得到响应。但是为什么它不起作用呢?

我刚刚在谷歌Chrome控制台上试用过,它运行得很好

jQuery.ajax({
    url: "http://zip.elevenbasetwo.com/v2/US/48867",
    cache: false,
    dataType: "json",
    type: "GET",
    success: function(result, success) {
     console.log(result);

    },
    error: function(result, success) {
      jQuery(".zip-error").slideDown(300);
    }
  });
没有错误。
可能您没有向URL调用发送正确的参数。你有HTML吗?

#国家
#邮政编码
输入标签吗?#国家是选择标签,#邮政编码是输入标签。发送时
url
的值是多少?(使用console.log()检查)以及为什么使用
jQuery
word而不是
$
?谢谢,HTML表单很正常,所有都是输入标记,只有#国家是选择标记。我是否正确地编写了url参数?