Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 02-22-2010, 04:16 AM problem in ajax
Skilled Talker

Posts: 97
Trades: 0
hi everyone..
i am using ajax to change the banner background while pressing on refresh
Note:it must be a background image because i will display data from database...


http://www.graphicano.com/isis/nile_crown2.php


please look at this link...

my problem is:
when i press refresh button in Firefox browser it changes the background and on pressing refresh again the background will change

but in internet explorer 8.0 it changes the background only for the first time and on pressing refresh again the background will not change.

how i can fix this problem ?? i want the user to press refresh at any time and the background will change.. not only for the first time?
at the same time it must be a background image because i will display text from database...
john_zakaria is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-22-2010, 07:13 PM Re: problem in ajax
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
IE locks the XMLHttpRequest object on first use and will not allow subsequent communications using the same object.
So it needs a bit of "hoop jumping" to make the object reusable.

Code:
var m_oRequest = null;

function setRequestObject() {
	if (m_oRequest == null) {
		m_oRequest = createRequestObject();
	} else if (m_oRequest) {
		m_oRequest.abort();
	}
}	

function createRequestObject() {
var l_oRequest = null;
	if (window.XMLHttpRequest) {
		try { 
				l_oRequest = new XMLHttpRequest();
			} catch (e) {
				l_oRequest = false;
			}
	} else if (window.ActiveXObject) {
		try {
				l_oRequest = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
			try {
					l_oRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {
			//		alert("Your browser does not support AJAX!");
					l_oRequest = false;
				}
			}
	}
	return l_oRequest;
}

Call setRequestObject() to create the XMLHttpObject this wiil check if the objects exists and aborts the existing (finished) operation if it does, this allows it to accept another operation.

The bug has been around ever since the object was introduced in IE, so you think they would have managed to fix it by now!!!
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to problem in ajax
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.20642 seconds with 12 queries