homepage Welcome to WebmasterWorld Guest from 54.145.252.85
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Ajax doesn't work when I run few AJAX events
alexey9

10+ Year Member



 
Msg#: 3494854 posted 6:01 pm on Nov 2, 2007 (gmt 0)

Hello guys,

I'm new to AJAX and I'm trying to build feature for my website using AJAX. I have like 20 images on the page and I need to call get some info using AJAX when user put mouse over that image.

My code works, but it stops working when I put mouse over few images during 1 or 2 seconds.

My code:

var AJAX = null;
if (window.XMLHttpRequest) {
AJAX=new XMLHttpRequest();
}else{
AJAX=new ActiveXObject("Microsoft.XMLHTTP");
}

AJAX.onreadystatechange = function() {
if (AJAX.readyState==4 ¦¦ AJAX.readyState=="complete"){
showAjax(AJAX.responseText, AJAX.status);
}
}

function showAjax(ajaxData, serverStatus) {
document.getElementById(someDiv).innerHTML = ajaxData;
}

I've tried to modify function to use array, but it doesn't work too:

var AJAXphoto = Array();

function sendAjaxPhoto (photoId, photo_big){
var url='http://www.site.com/ajaxShowPhoto.php?photoId=' + photoId + '&photoBig=' + photo_big;
AJAXphoto[photoId].open("GET", url, true);
AJAXphoto[photoId].send(null);
}

function showPhoto (ajaxData, serverStatus){
photoWindow = document.getElementById("infoWindow");
photoWindow.innerHTML = ajaxData;
}

big function that creates images(....){

....

if (window.XMLHttpRequest) {
AJAXphoto[photoId] = new XMLHttpRequest();
}else{
AJAXphoto[photoId] = new ActiveXObject("Microsoft.XMLHTTP");
}

AJAXphoto[photoId].onreadystatechange = function() {
if (this.readyState==4 ¦¦ this.readyState=="complete"){
showPhoto(this.responseText, this.status);
}
}

....

event.addListener(image, "mouseover", function() {
sendAjaxPhoto(photoId, photo_big);
}

....

}

Firebug (Firefox extension for JavaScript debugging) shows errors like this one when I put mouse over few images:

[Exception... "Component returned failure code: 0xc1f30001 (NS_ERROR_NOT_INITIALIZED) [nsIXMLHttpRequest.send]" nsresult: "0xc1f30001 (NS_ERROR_NOT_INITIALIZED)" location: "JS frame :: javascript: eval(__firebugTemp__); :: anonymous :: line 1" data: no]
mc(mouseout clientX=0, clientY=0, div#map)main.js (line 240)
ne(mouseout clientX=0, clientY=0)main.js (line 540)
iv(mouseout clientX=0, clientY=0)

Can you guys help me to fix it please? I'm trying to fix it for a week already, but still can't make it work.

 

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved