hi anyone know why there is syntax error to this?
if i write this can i get a attribute frm the json file?
is it because how i put the json data in html wrongly?
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject(“Microsoft.XMLHTTP”);
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
var addrField = document.getElementById("myDiv");
var card = eval('('+xmlhttp.responseText+')'); // they say the error is here
addrField.value = card.places.place.name.value;
}
u mean that i cant use this html url to be retrieve data in xmlhttp.open(“GET”,“HTMLPage3.htm”,true);
what i mean was HTMLPage3.htm store the json data in the html and i got to use this url to work with the ajax
it jus retrieve the name and coordinates
Let me try to explain this using different words, so that they might be understood.
The entire contents of the html file will be returned as data to the request. If you want the data to be interpreted as json data, the entire contents of the file must be json data.
okay if i use the json file right …then it shld be able to get the name and coordinate but how to write in ajax ?then i will like to ask is my format of json declare wrongly?
You have two different places there.
Shouldn’t each place be separated by a comma, and shouldn’t yoiu use an array to contain multiple items, such as those places?
oh that one is okay already but can i ask you using ajax right how am i goin to put the data retrieve from the json data into the programmatic dojo border container…i try out but it don’t work
this is one code…i not sure why it don’t work in the border container…the htmlpage4 is json data inside
function getInfoContent(graphic) {
function ajaxRequests() {
var activexmodes = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
if (window.ActiveXObject) { //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)
for (var i = 0; i < activexmodes.length; i++) {
try {
return new ActiveXObject(activexmodes[i])
}
catch (e) {
//suppress error
}
}
}
else if (window.XMLHttpRequest) // if Mozilla, Safari etc
return new XMLHttpRequest()
else
return false
}
var mygetrequests = new ajaxRequests()
mygetrequests.onreadystatechange = function() {
if (mygetrequests.readyState == 4) {
if (mygetrequests.status == 200 || window.location.href.indexOf("http") == -1) {
var bookss = eval("(" + mygetrequests.responseText + ")") //retrieve result as an JavaScript object
var rssent = bookss.infos.info
for (var i = 0; i < rssent.length; i++) {
// alert(mygetrequests.responseText);
var placeImg = ""
var txt = ""
// placeImg += rssent[i].descImg
txt += rssent[i].desc
var shorttxt = ""
shorttxt += txt.substring(0, 30);
var bc = new dijit.layout.BorderContainer({ style: "font-size: 11pt; height: 574px; width:739px; border:0px;" });
var c1 = new dijit.layout.ContentPane({
region: "top",
style: "height: 11.5%; width: 100%; color: black; background-color: transparent; border:0px;",
content: "<table><div id = \\"mydiv\\">" + shorttxt + "<font color = '#0000FF' size = '1'><a onclick='showmore();'><u> More...</u></a></div></td></table>"
});
bc.addChild(c1);
}
}
else {
alert("An error has occured making the request")
}
}
return bc.domNode;
}
mygetrequests.open("GET", "HTMLPage4.htm", true)
mygetrequests.send(null)
}
this kind var bc = new dijit.layout.BorderContainer({ style: “font-size: 11pt; height: 574px; width:739px; border:0px;” });
instead of the div …
so why it the border container cannot work but if i alert each of the retrieve it call the data but the border container cannot work …please help me!!!
Once the most significant problems with the code are sorted out, we can then focus on the issue at hand without being distracted by other problems.
Things like automatic semicolon insertion is known to cause unexpected problems with your code, so don’t rely on it.
so ?? i put the semi colon in liao le …also can not work…cause i return the bc.domNode …but it say domNode null …is it i put at the wrong area or what why the ajax can retrieve data but can’t put inside the border container…please help me solve it…