zoukankan      html  css  js  c++  java
  • ajax 返回数据 无法得到其属性的解决办法

    当我们用ajax无法 得到其属性。正常情况下是:

    <script type="text/javascript">
            function useAjax(sendUrl,name){

                $.ajax({
                    type: "POST",
                    url: sendUrl,
                    data: { txtCode: $("#txtCode").val() },
                    datatype: "json",
                    timeout: 20000,
                    success: function (json) {

          //无法使用的属性
                       alert(json.msg);
                  
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                       
                    }
                } );
            }
        </script>

    如无法弹出其正常的属性值则需要用下面的方法解决:

    <script type="text/javascript">
            function useAjax(sendUrl,name){

                $.ajax({
                    type: "POST",
                    url: sendUrl,
                    data: { txtCode: $("#txtCode").val() },
                    datatype: "json",
                    timeout: 20000,
                    success: function (json) {
                       //正常的使用的属性
                        json=JSON.decode(json);
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        alert(1);
                    }
                } );
            }
        </script>

  • 相关阅读:
    ( 转 ) Mysql group_concat 的反向应用实现(Mysql列转行)
    ( 转 ) 优化 Group By -- MYSQL一次千万级连表查询优化
    ( 转 ) mysql复合索引、普通索引总结
    ( 转 ) 数据库BTree索引、Hash索引、Bitmap位图索引的优缺点
    ( 转 ) mysql 实战 or、in与union all 的查询效率
    ( 转 ) MySQL高级 之 explain执行计划详解
    ( 转 ) UML 类图
    ( 转 ) .net 操作 JWT
    windows 常用命令
    windows 执行bat脚本
  • 原文地址:https://www.cnblogs.com/WZH75171992/p/4121776.html
Copyright © 2011-2022 走看看