943,175 Members | Top Members by Rank

Ad:
Aug 31st, 2010
0

Multiple Get Element By Id Ajax Functions

Expand Post »
I'm using an ajax function to call multiple php files to the same HTML web page. Dividends must be dynamic the data is stock prices. It seems that the last stock price is only updating the other 9 are not is their a limitation to the number of ajax functions used in a single web page. Here is the code I'm using 10 times is separate div's

<div id="squotes_div7"><script type="text/javascript">

function ajaxFunction() {
var xmlHttp;

try {
// Firefox, Opera 8.0+, Safari
xmlHttp = new XMLHttpRequest();
} catch (e) {
// Internet Explorer try
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
alert("Your browser does not support AJAX!");

return false;
}
}
}

xmlHttp.onreadystatechange = function() {
// only if req is "loaded"
if (xmlHttp.readyState == 4) {
// only if "OK"
if (xmlHttp.status == 200 || xmlHttp.status == 304) {
results = xmlHttp.responseText;
document.getElementById("squotes_div7").innerHTML = results;
} else {
innerHTML="ajax error:\n" + xmlHttp.statusText;
}
}
}

xmlHttp.open("GET", "/quotes/eurusdpr.php", true);
xmlHttp.send(null);

}

ajaxFunction();
</script></div>
Last edited by omar_ghassan; Aug 31st, 2010 at 3:09 pm.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
omar_ghassan is offline Offline
2 posts
since Aug 2010
Sep 1st, 2010
0
Re: Multiple Get Element By Id Ajax Functions
try using "var q = new ajaxFunction();" when you are calling ur ajax function. this will probably help you
Last edited by fatihpiristine; Sep 1st, 2010 at 5:04 pm.
Reputation Points: 6
Solved Threads: 19
Posting Whiz in Training
fatihpiristine is offline Offline
283 posts
since Sep 2007
Sep 22nd, 2010
0
Re: Multiple Get Element By Id Ajax Functions
i tried to add var but no use. Any help please
Reputation Points: 10
Solved Threads: 0
Newbie Poster
omar_ghassan is offline Offline
2 posts
since Aug 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: need random images in 4 cells - can anyone help?
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Accessing a variable defined in a function, outside the function





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC