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>

  • 相关阅读:
    Angular之filter学习
    Jupyter notebook 安装,初步使用
    Python排序算法
    获取相对于控件的鼠标坐标
    使用PYTHON实现docx文档的读写
    MATLAB 物体识别算法说明:vision.ForegroundDetector, vision.BlobAnalysis
    MATLAB 例子研究 Motion-Based Multiple Object Tracking
    MATLAB 图像处理——Contrast Enhancement Techniques
    MATLAB 图像操作基础
    MATLAB 图像分类 Image Category Classification Using Bag of Features
  • 原文地址:https://www.cnblogs.com/WZH75171992/p/4121776.html
Copyright © 2011-2022 走看看