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>

  • 相关阅读:
    函数 定义与调用
    python文件基本操作(读,写,追加)
    python集合深浅copy
    day6 bytes类型用法
    字典的增删改查
    一个文件启动Django(基础中的基础)
    Django错误集
    Linux的Shell
    Linux的Vim文本编辑器
    Linux管道符和重定向与环境变量
  • 原文地址:https://www.cnblogs.com/WZH75171992/p/4121776.html
Copyright © 2011-2022 走看看