<tfoot id='pE2uM'></tfoot>

      <legend id='pE2uM'><style id='pE2uM'><dir id='pE2uM'><q id='pE2uM'></q></dir></style></legend>
      • <bdo id='pE2uM'></bdo><ul id='pE2uM'></ul>
    1. <i id='pE2uM'><tr id='pE2uM'><dt id='pE2uM'><q id='pE2uM'><span id='pE2uM'><b id='pE2uM'><form id='pE2uM'><ins id='pE2uM'></ins><ul id='pE2uM'></ul><sub id='pE2uM'></sub></form><legend id='pE2uM'></legend><bdo id='pE2uM'><pre id='pE2uM'><center id='pE2uM'></center></pre></bdo></b><th id='pE2uM'></th></span></q></dt></tr></i><div id='pE2uM'><tfoot id='pE2uM'></tfoot><dl id='pE2uM'><fieldset id='pE2uM'></fieldset></dl></div>
    2. <small id='pE2uM'></small><noframes id='pE2uM'>

      1. Jquery - 未捕获的类型错误:无法使用“in"运算符来搜索“324"

        Jquery - Uncaught TypeError: Cannot use #39;in#39; operator to search for #39;324#39; in(Jquery - 未捕获的类型错误:无法使用“in运算符来搜索“324)
        <i id='sumXF'><tr id='sumXF'><dt id='sumXF'><q id='sumXF'><span id='sumXF'><b id='sumXF'><form id='sumXF'><ins id='sumXF'></ins><ul id='sumXF'></ul><sub id='sumXF'></sub></form><legend id='sumXF'></legend><bdo id='sumXF'><pre id='sumXF'><center id='sumXF'></center></pre></bdo></b><th id='sumXF'></th></span></q></dt></tr></i><div id='sumXF'><tfoot id='sumXF'></tfoot><dl id='sumXF'><fieldset id='sumXF'></fieldset></dl></div>

                  <tbody id='sumXF'></tbody>
              1. <tfoot id='sumXF'></tfoot>
                • <bdo id='sumXF'></bdo><ul id='sumXF'></ul>

                  <legend id='sumXF'><style id='sumXF'><dir id='sumXF'><q id='sumXF'></q></dir></style></legend>

                  <small id='sumXF'></small><noframes id='sumXF'>

                  本文介绍了Jquery - 未捕获的类型错误:无法使用“in"运算符来搜索“324"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试通过 ajax 发送 Get 请求,并以 html 格式输出服务器返回的 json 数据.

                  I'm trying to send a Get request by ajax and output json data that is returned by server in html.

                  但是,我遇到了这个错误.

                  But, I got this error.

                  Uncaught TypeError: Cannot use 'in' operator to search for '324' in 
                  [{"id":50,"name":"SEO"},{"id":22,"name":"LPO",}]
                  

                  这是我通过ajax向php文件发送Get请求的代码.当我使用 $.each 方法时,它得到了我在上面显示的错误.

                  This is my code that sends a Get request to php file by ajax. When I use $.each method, it get the error that I showed in the above.

                  parentCat.on('change', function(e){
                      parentCatId = $(this).val();
                  
                      $.get(
                          'index.php?r=admin/post/ajax',
                          {"parentCatId":parentCatId},
                          function(data){                     
                              $.each(data, function(key, value){
                                  console.log(key + ":" + value)
                              })
                          }
                      )
                  
                  })
                  

                  这是我的PHP代码,以json格式返回查询结果.

                  This is my PHP code that returns query result in json format.

                  public function actionAjax(){
                  
                      $parentCatId=$_GET['parentCatId'];
                  
                          $catData = Category::getTargetCategoryData($parentCatId);
                  
                          echo CJSON::encode($catData);
                          Yii::app()->end();
                  
                  }
                  

                  这个php输出的json数据是这样的.

                  json data outputted by this php is like this.

                  [{"id":50,"name":"SEO"},{"id":22,"name":"LPO",}]
                  

                  有人知道如何解决这个问题吗?

                  Anyone knows how to fix this problem?

                  请帮帮我.提前致谢:)

                  Please help me out. Thanks in advance :)

                  推荐答案

                  您有一个 JSON 字符串,而不是一个对象.告诉 jQuery 您希望得到 JSON 响应,它会为您解析它.要么使用 $.getJSON 而不是 $.get,或将 dataType 参数传递给 $.get:

                  You have a JSON string, not an object. Tell jQuery that you expect a JSON response and it will parse it for you. Either use $.getJSON instead of $.get, or pass the dataType argument to $.get:

                  $.get(
                      'index.php?r=admin/post/ajax',
                      {"parentCatId":parentCatId},
                      function(data){                     
                          $.each(data, function(key, value){
                              console.log(key + ":" + value)
                          })
                      },
                      'json'
                  );
                  

                  这篇关于Jquery - 未捕获的类型错误:无法使用“in"运算符来搜索“324"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Is PHP or PHP based web framework stateful or stateless?(PHP 或基于 PHP 的 Web 框架是有状态的还是无状态的?)
                  How to parse django style template tags(如何解析 django 样式模板标签)
                  What is a good setup for editing PHP in Emacs?(在 Emacs 中编辑 PHP 的好设置是什么?)
                  How to check whether specified PID is currently running without invoking ps from PHP?(如何在不从 PHP 调用 ps 的情况下检查指定的 PID 当前是否正在运行?)
                  What#39;s the difference between escapeshellarg and escapeshellcmd?(escapeshellarg 和escapeshellcmd 有什么区别?)
                  php in background exec() function(php 后台 exec() 函数)
                    <bdo id='1dgO5'></bdo><ul id='1dgO5'></ul>
                    <i id='1dgO5'><tr id='1dgO5'><dt id='1dgO5'><q id='1dgO5'><span id='1dgO5'><b id='1dgO5'><form id='1dgO5'><ins id='1dgO5'></ins><ul id='1dgO5'></ul><sub id='1dgO5'></sub></form><legend id='1dgO5'></legend><bdo id='1dgO5'><pre id='1dgO5'><center id='1dgO5'></center></pre></bdo></b><th id='1dgO5'></th></span></q></dt></tr></i><div id='1dgO5'><tfoot id='1dgO5'></tfoot><dl id='1dgO5'><fieldset id='1dgO5'></fieldset></dl></div>
                      <legend id='1dgO5'><style id='1dgO5'><dir id='1dgO5'><q id='1dgO5'></q></dir></style></legend>
                        <tbody id='1dgO5'></tbody>

                      <tfoot id='1dgO5'></tfoot>

                      <small id='1dgO5'></small><noframes id='1dgO5'>