简体   繁体   中英

fetch json array and append data in another page

I am trying to pass a json array to another page with jquery and on that another page I want to bind the data to the respective element.This is my ajax request:

$.ajax({
    type: "GET",
    url: 'url of the php page',
    data: {'json':jsondata},
    dataType :'json',
    async: false,
    encode: true
}).done(function(data) {
    window.location.href = 'anotherpageurl?res='+encodeURIComponent(JSON.stringify(data));
});

This is the json response from the url that i receive:

{
"data": [
{
"full_name": "xxxx",
"employee_id": "xxxxx",
"imageUrl": "xxxx",
"dname": "xxxx"
},
{
"full_name": "xxxxx",
"employee_id": "xxxxx",
"imageUrl": "xxxx",
"dname": "xxxx"
}
]
}

Use data not data(data)

Following information might help you URL encoding refer below,

https://en.wikipedia.org/wiki/Percent-encoding

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM