Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
81
rated 0 times [  86] [ 5]  / answers: 1 / hits: 18271  / 9 Years ago, thu, may 28, 2015, 12:00:00

I want to send json data through url to next html page. I checked it by emulator as I am working for mobile app, the url could not redirect to next page it is crashing at the moment what is the reason behind this. How can I parse it on next page .I am new to the jquery any idea? my json data contains result of two different sql queries in an array



 $.ajax({
type : POST,
datatype : json,
url : http://Localhost/phpBB3/check_pass.php?username=+ username + &password=+ password+&f=68,
success: function(data){
alert(data);

window.location.href=source/testmenu.html?varid= + data +&username= + username +&password= + password;
}
});


This is the code on next page



$(document).ready(function GetUrlValue(VarSearch){
var SearchString = window.location.search.substring(1);

var arr = SearchString.split('&');
console.log(arr);
//Set session variables
var username = arr[1].split('=')[1];
var password = arr[2].split('=')[1];
document.getElementById('username').value = username;
document.getElementById('password').value = password;
)};

More From » jquery

 Answers
4

in your case in first page urlencode json



window.location.href=source/testmenu.html?varid= + encodeURIComponent(data) +&username= + username +&password= + password;


and in next page



var data= arr[0].split('=')[1];
var recieved_json = $.parseJSON(data);

[#66435] Tuesday, May 26, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
albert

Total Points: 652
Total Questions: 105
Total Answers: 108

Location: Pitcairn Islands
Member since Fri, Oct 15, 2021
3 Years ago
;