I want redirect my getJSON response to another html page below is the code for both the htmls
index.html
$(document).ready(function() {
alert("load");
$.getJSON("http://10.0.2.2:8080v1/service/26/1",
function(data) { //want to redirect this response display.html
$.each(data, function(id, obj){
$.each(obj, function(propName, value){
// console.log(propName + ": " + value);
alert("propName: "+propName+" value: "+value);
});
});
});
document.addEventListener("deviceready", onDeviceReady, true);
});
function onDeviceReady(){
navigator.notification.alert("PhoneGap is working");
}
</script>
</head>
<body>
</body>
</html>
display.html
In this I have code to display the response data in the form of table. Can you help me out now on how to send the getJSON response to display.html and use in this
<body>
<table width="100%" cellspacing="3">
<tr align="center">
<td bgcolor="#474646" style="color: #fff; >first column</td>
<td bgcolor="#474646" style="color: #fff; >second column</td>
<td bgcolor="#474646" style="color: #fff; >third column</td>
</tr>
<tr align="center">
<td>firstcolumn</td>
<td>secondcolumn</td>
<td>thirdcolumn</td>
</tr>
</table>
</body>
Do you mean that you want to redirect your page to display.htm once your getJSON has completed? If so, try this:
Also, it looks like your URL is incorrectly formatted. I think that you are missing a “/” before “v1” so that it should look like this “http://10.0.2.2:8080/v1/service/26/1”
EDIT:
From your comments, it sounds like you just want to load the contents of display.html into the body of index.html. If that is the case, I don’t think you want to use getJSON, I think you just want ‘load’ see below.
Make sure that you get the path to display.htm correct.