<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"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                    <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'>