JS: String into JSON data, and JSON to string method iframe gets the data passed by the parent.

Source: Internet
Author: User

String into JSON data, and JSON to string method

// Convert to JSON adinfo=json.parse (adinfo)// Convert to String adinfo=json.stringify (adinfo)

Approximate process:

  

var gdt_adinfo=[];

The parent page gets the data through the interface:

this. Url="http://gjs.adwo.com/gjs/gad_i?sdkVersion="+sdkversion+" &n=1&gp= "+gp;

Ways to get data post-processing:

 This. ajaxcallback=function (gdt_ajax_obj) {if(4= = Gdt_ajax_obj.xmlhttp.readyState && $==gdt_ajax_obj.xmlhttp.status) {                Try{                    vardatatext=Gdt_ajax_obj.xmlhttp.responseText; vardata = eval ("("+datatext+")"); if(data.result==1){                        Try{                            varOuturl=Data.ad.outurl; varIspad=1; Ispad=0; var_f = Document.createelement ("iframe"); var_n ="IFRGDT"; _f.name= _f.id =_n; _f.setattribute ("frameborder","0"); _f.scrolling="No"; _f.height= -; _f.width= the;                            Gdt_adinfo.push (Datatext); varSrc='inmobi_tw.html?protocol_pre='+encodeURI (Protocol_pre); _F.SRC=src; varD = document.getElementById ('GDT');                            D.appendchild (_f); SetTimeout (Gdt_ajax_obj.gdt_show,timeout* +); }                        Catch(e) {}}} Catch(e) {} }}

Two of these are stored data:

var datatext=gdt_ajax_obj.xmlhttp.responseText;                     var data = eval ("("+datatext+")"); Gdt_adinfo.push (datatext);

The sub-page receives the data and reverts to the JSON format:

var adinfo =parent.gdt_adinfo;      Adinfo=json.parse (adinfo)      var adinfoad=adinfo.ad;      Console.log (adinfoad.html)

  

JS: String into JSON data, and JSON to string method iframe gets data passed from parent

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.