473,394 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

AJAX Not Working In Firefox

I have the following javascript which works in either IE or Firefox but
not on both.

When I set the code to

http_request.open('POST', url, true) - Works in IE only
http_request.open('GET', url, true) - Works in Firefox only; Does not
refresh in IE.

How do I resolve this?

Thanks in advance.
=====================================

The page that uses AJAX is http://www.ubelt.com

http://www.ubelt.com/ub/apps/ajax/ajaxlatestphotos.js (for Full Code)

function makeHttpRequest(url, callback_function, return_xml)
{
var http_request = false;

if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml');
}

} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}

if (!http_request) {
alert('Unfortunatelly you browser doesn\'t support this
feature.');
return false;
}
http_request.onreadystatechange = function() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
if (return_xml) {
eval(callback_function +
'(http_request.responseXML)');
} else {
eval(callback_function +
'(http_request.responseText)');
}
} else {
//alert('There was a problem with the request.(Code: ' +
http_request.status + ')');
}
}
}
http_request.open('POST', url, true);
http_request.send(null);
}

Jul 18 '06 #1
5 8101
Guestion why don't u use prototype? pretty easy and it work's in every
browser.

http://wiki.script.aculo.us/scriptac...show/Prototype

example:
new Ajax.Updater('mydiv', '/foo/bar', {method:'post',
postBody:'thisvar=true&thatvar=Howdy', asynchronous:true,
evalScripts:true});

evalScripts on the end means that when the ajax page you are calling
contains for example <script>alert('hello');</scriptit will execute
that the other stuff just echo't will be outputted to mydiv.

i give you this because i stoped using my own crap because this stuff
is alway's working

Hope this helps

Danny R wrote:
I have the following javascript which works in either IE or Firefox but
not on both.

When I set the code to

http_request.open('POST', url, true) - Works in IE only
http_request.open('GET', url, true) - Works in Firefox only; Does not
refresh in IE.

How do I resolve this?

Thanks in advance.
=====================================

The page that uses AJAX is http://www.ubelt.com

http://www.ubelt.com/ub/apps/ajax/ajaxlatestphotos.js (for Full Code)

function makeHttpRequest(url, callback_function, return_xml)
{
var http_request = false;

if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml');
}

} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}

if (!http_request) {
alert('Unfortunatelly you browser doesn\'t support this
feature.');
return false;
}
http_request.onreadystatechange = function() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
if (return_xml) {
eval(callback_function +
'(http_request.responseXML)');
} else {
eval(callback_function +
'(http_request.responseText)');
}
} else {
//alert('There was a problem with the request.(Code: ' +
http_request.status + ')');
}
}
}
http_request.open('POST', url, true);
http_request.send(null);
}
Jul 18 '06 #2
another thing...

stuff like this:
document.getElementById('ajax-latestphotos').innerHTML = html_content;

will become this:
$('ajax-latestphotos').innerHTML=html_content

Jul 18 '06 #3
Sjigger said the following on 7/18/2006 4:57 AM:
Guestion why don't u use prototype?
You should search the archives for articles about prototype.
pretty easy and it work's in every browser.
No it doesn't.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 18 '06 #4

Thanks for the response.

However, any of you guys know why this isn't working on both browsers?
Is there an alternative code that works on both?

Randy Webb wrote:
Sjigger said the following on 7/18/2006 4:57 AM:
Guestion why don't u use prototype?

You should search the archives for articles about prototype.
pretty easy and it work's in every browser.

No it doesn't.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 18 '06 #5

Danny R написав:
if (return_xml) {
eval(callback_function +
'(http_request.responseXML)');
} else {
eval(callback_function +
'(http_request.responseText)');
}
You can use http_request.responseXML only for appointed content type:

var respType = http_request.getResponseHeader("Content-Type");
if (respType == 'text/xml')
{
// process http_request.responseXML
}
else
{
// process http_request.responseText
}

Does not refresh in IE.
It may be caused by caching.
Simple solution were posted here
http://groups.google.com.ua/group/co...33ea0f52689067

Instead of
var url = '/ub/apps/ajax/latestphotosxml.aspx';
use
var url = '/ub/apps/ajax/latestphotosxml.aspx?'+ Math.random();

Jul 19 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: dougwig | last post by:
I'm trying to handle the scenario where a user's session times out and and their ajax request triggers a redirection by the webserver (302 error?). I'm using Prototype 1.4 and the my works great...
4
by: evgenyg | last post by:
Hello ! We have the following situation - when Ajax request is sent what's being returned by the server is usually an XML (which is used for DOM updates) but sometimes it's HTML which is a whole...
3
by: noballack | last post by:
I've got a problem, I'm working with Ajax in a web with a form with a list of checkbox added to the form via an Ajax.Updater method. These added checkboxs are not been sended by the form if I use...
25
by: meltedown | last post by:
This is supposed ot be an example: http://www.ajaxtutorial.net/index.php/2006/11/30/simple-ajax-using-prototype-part-2/ It says : This example is probably the simplest example you will ever...
5
by: Steve Wright | last post by:
I have an AJAX routine on a webpage that is working in IE6, but not IE7 or Firefox v2.0.0.2 The webpage is http://www.a-drop-in-the-ocean.co.uk/CWS/monitor10bins.php?quarry=401 The AJAX...
8
by: cyqotiq | last post by:
First, let me state that this is not necessarily a Firefox problem, as I haven't fully tested in IE just yet. Second, let me state that this is not the typical "getElementById not working Firefox"...
29
by: zalek | last post by:
I am writing application with Ajax in sync mode - xmlHttp.open("GET", url, false). I noticed that in FireFox handler doesn't starts. It starts when I use xmlHttp.open("GET", url,true). I need to...
3
by: sarika | last post by:
Hi all I m making a website in which i have used ajax technology . When i make a page request throght ajax it works fine in IE but giving problems in Mozilla .In mozila i m getting 403 status code...
7
by: mike57 | last post by:
The minimal AJAX script below works in Firefox, but not in IE, Opera, or Chrome. I could use some suggestions or referrals to resources that will help me get the script working in other browsers. ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.