Blogger Information
Blog 175
fans 1
comment 0
visits 384663
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
JSON字符串转换为JSON对象
dxp2tq的博客
Original
2499 people have browsed it

result = "{"msg":"修改成功!","obj":null,"success":true}" 如何取到 msg的值

alert(result ); 若是字符串应当先转化为obj;

字符串: {"status":1,"msg":"success"}

  •     方法一:var obj = eval('(' + result + ')');

  •     方法二:var obj = JSON.parse(result ); //由JSON字符串转换为JSON对象[/b]

  •     方法三:var obj = result .parseJSON(); //由JSON字符串转换为JSON对象

    if(obj .status == 1){
       alert('yes');
    }

json: [object Object]

    if(result .status == 1){
       alert('yes');
    }

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post