什么是json数据格式,即理解? [英] what is the json data format ie understands?

查看:262
本文介绍了什么是json数据格式,即理解?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在调用php脚本来使用ajax获取数据。它在chrome和其他浏览器上没有任何问题,但在IE上(当然)它不起作用。

I am calling a php script to get the data using ajax. It works without any problems on chrome and other browsers but on IE (of course) it does not work.

我的数据格式如下:

[1234000000000,56]



<这是我试图调用以获取abobe值的脚本:

this is the script I am trying to call to get the abobe value:

$.ajax({

        url: 'get_cpu.php', 
        success: function(data) {
          var myObj = JSON.parse(data); 
                        alert(obj);

我尝试以多种不同的格式输出这个文件,让IE好运没有任何运气。如何在json中格式化这些数据那么ie了解?我真的很感激任何见解?

I tried outputing this file in many different formats to make IE happpy without any luck. How can I format this data in json so that ie understands? I really appreciate any insight?

祝你好运,

推荐答案

旧版本的IE没有内置的 JSON 对象。因此, JSON.parse 它不存在。它与你的JSON格式无关。

Old versions of IE don't have the built-in JSON object. Therefore, JSON.parse doesn't exist. It has nothing to do with your JSON format.

因为你是usi ng jQuery,你不需要担心JSON解析;它会照顾它。在 $。ajax 调用中,添加 dataType:'json'。这将使jQuery自动为您解析。

Since you are using jQuery, you don't need to worry JSON parsing; it will take care of it. In your $.ajax call, add dataType: 'json'. This will make jQuery parse it for you automatically.

$.ajax({
    url: 'get_cpu.php',
    dataType: 'json',
    success: function(data) {
        console.log(data);
    }
});

如果您不使用jQuery,则必须使用 JSON 替换库,例如 json3.js

If you weren't using jQuery, you would have to use a JSON replacement library, like json3.js.

这篇关于什么是json数据格式,即理解?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆