I have a requirement of populating an iframe (HTML component) with a json data. I have a java script function which on page load loads the json data. But, the iframe component is not able to load the data.
My code implementation is:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script
src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
<script src="jquery.loadJSON.js"></script>
<script>
function populateData()
{
window.document.getElementById('one').style.color='red';
var data = {"d1":"http://www.w3schools.com/"};
$('form').loadJSON(data);
alert('start');
}
window.onload = populateData;
</script>
</head>
<body>
<form>
<label id="one" for="Address">Address:</label>
<iframe id="d1" width="100%" height="50%" src="about:blank">
<p>Your browser does not support iframes.</p>
</iframe>
<br> <br>
</form>
</body>
</html>
Just change the
srcattribute on the iframe. No need, or use, for JSON here.As far as I can tell, the url you’re querying returns HTML, and not JSON. You just want to show the map, yeah?