JQuery :: Code - Repeatable - With Firefox 3 And AJAX
Sep 9, 2009
I have found a problem with Firefox 3 and AJAX, and give code to replicate it below.
The problem is when you have a resource, e.g. /docs/1234, which is fetched both directly as a web page and as AJAX (XMLHttpRequest). The server detects these cases based on the X-Requested-With: XMLHttpRequest header, and sends back different content, e.g. just a raw div or wrapped in a full HTML page.
The problem is when you use a jQuery AJAX request to fetch the page again. If Firefox has /docs/1234 in its cache, then load('/docs/1234') wrongly gets the non-XHR version of the page, and this is the version it will insert into the DOM. This screws up the page, since you get a second copy of the layout wrapper HTML inside the original layout.
The code below replicates this:
- The home page (/) fetches /docs/1234 into the lower pane using XHR
- click on the link to fetch /docs/1234 as a full HTML page
- click back, and the main page ends up inserting the full /docs/1234
HTML into the lower pane
You can see that I've set a Cache-Control: header, which ought to prevent /docs/1234 from being cached at all, but that doesn't seem to make a difference. You can confirm it's present using curl -v [url]
This problem doesn't occur with Opera. Looking at the server logs, when you hit Back you see that $.load fetches a new copy of the page, so the AJAX request isn't using a local cached copy. (This is true even without setting the Cache-Control header) So arguably this is a Firefox problem. However, since part of the purpose of jQuery is to abstract away and compensate for browser differences, I thought I'd raise it here first.
The only workaround I can think of is to use a different URL for XHR requests, e.g. add '?xhr=true' to the end.
To run this code, you'll need ruby and 'gem install sinatra'
I have what I thought was a simple piece of code to count characters in a text area. The code works fine in FF and safari, but not in IE. Can someone explain if the problem is my code or something else.
I have created a new theme for Rapidweaver and integrated some neat JQuery animated sliding panels and frankly I was feeling pretty chuffed with my efforts as I am far from a JQuery expert.[URL]..In the side panel on the left, I have embedded a Titter feed widget, lifting the code direct from Twitter. In Safari, Chrome, Opera and even jolly old IE this works fine. But Firefox has a fit and displays a blank page - or just plain won't load. If I remove the Twitter widget the page loads perfectly happily. If I disable Javascript in FF, the page loads (but there is no animation etc) - so there is clearly a JQ/Javascript/Twitter script issue going on here that is causing FF to freak out...
Of course the simple solution is not to add the Twitter feed, but since this is exactly one of the uses I was planning for this sliding panel, that's a fat 'non' option. All the JQuery code I have used for the theme has 'no conflict' calls and I have even added specific calls for specific code - so stuff like:
This code works on ie7, but it does not work on firefox. it just shows a alert when focus occur on an element. you can just click something on the page and you will see alert at ie7.
When i use $.get without alert() my code not working into asp.net ( updatePanel and ScriptManager for asp.net ). if i use this code in firefox dont work:
Why does my below code not work in Safari and firefox? The below code does not call my page method.but it works on IE. Is there any thing need to enable Ajax mehod call.
Whenever I open the page in Chrome, my "Hello" message pops up, but in any other of my browsers, it doesn't. This page is also being hosted basically from a file on my computer, on the C drive.
I've been building a site that will rely very heavily on ajax calls to save server load and to spice things up a bit. So, so far I've successfully made several different ajax calls in Firefox. I'm mainly using the following code
I have a jQuery code to allow users to login using a lightbox (URL...) and immediately start downloading files, without being redirected or having the page reloaded. It's perfectly working in Firefox but Internet Explorer keeps showing the login box until I reload the page [code]
I am using jquery ajax to retrieve data from an asp.net web service. It works ok in IE8; but when I tried it on Firefox (3.6 or so), it generated an error: parsererror
The post always comes back a success in both IE and Firefox. The html response comes back as expected when using IE. However, the html response when using Firefox brings back an error from the server instead of what is expected. I'm not sure why there is a difference when using Firefox. My guess is that the content-type that the server is expecting is not correct when using Firefox.
The simple test code below validates a few fields successfully when tested using Safari, Opera, Firefox and ChromeDatepicker does not work in IE, although the validations do work as expected. Is there an issue with datepicker and IE? Is there a condition in my code that inhibits IE?
//// page code follows //// <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
I have an Ajax script which works fine in IE, Opera, etc, but not in FF 3.6. It appears the data sent is not recognized. My debug alert to display a simple variable sent is blank. In other browsers it displays fine. I'm developing on my PC so shouldn't have the cross domain issue, I don't think?
Here is the code function ajaxRequest() { $.ajax({ type: "POST", url: 'WTE_HTTP_Submit.cfm',
Attached is a sample html file (named jqmleak.html - rename it to remove the txt extension and drop it into your web server to test for yourself) that I've put together to demonstrate a memory leak with the $.ajax function in jQuery 1.6.1 when run in Firefox 4.0.1. The file loads jQuery 1.6.1 from the Google API CDN. Next, a simple function is defined that runs $.ajax to request the html file itself. This function is then set to run once every second using setInterval.
In Firefox 4.0.1, on both Win XP and Linux (ubuntu 10.10, 64-bit), I can watch the amount of memory consumed by Firefox gradually rise. It takes a few minutes for the problem to be observed, because initially the memory will decrease with no other activity in the browser. Then after about 5 minutes or so, I can watch the memory used by Firefox slowly but steadily increase. I can use the handy 'about:memory' tool in Chrome to monitor this alongside other browsers. Chrome, Opera, and IE do not exhibit the same problem with this test. Their memory usage will vary within a range of about 2 or 3 mb, but over a long period of time they do not increase their total amount of memory used. This problem is only happening in Firefox 4.0.1 as far as I can tell (I also used safe mode in Firefox to make sure no plugins were interfering with the test). I have tried both GET and POST methods with the $.ajax call, and with the cache setting both enabled and disabled. The result is the same.
Is this a jQuery problem, or maybe instead a bug with Firefox? I see similar bugs reporting memory leaks in other situations, but usually specific to IE. I was about to report a bug for this, but I thought I'd check here first to see if anyone can duplicate this problem, and/or point out what I should do to prevent the memory leak in Firefox.
I built jQuery UI tabs with jQuery UI Accordion embedded into each tab. It works fine on my local machine, it also works fine on all browsers in the development server except using Mozilla Firefox.
I have created a very simple JavaScript code to display larger images of a thumbnail image on the main section of a website. It works fine in FF3 however in IE 7 is giving me an error code of Invalid argument on line 6 character 1. The funny thing is I have used this exact code in another site and it worked fine with IE 7.
I want to get the colour in HEX format using "thing.style.backgroundColor". Like "#FFFFFF" or whatever. IE gives this but FF gives it as "rgb(0,0,0)" format.
Is there a simple function/method of getting it as hex? (or a conversion function)
This code works inside my coffee cup test browser but when i test in other browsers it doesnt work at all. none of the features work, drag and drop, highlight text on focus, and cursor change on mouse over.heres a simple code i put together.
<html> <head> <title>sample</title> <script type="text/javascript"> function handleMouseMove(oEvent) {
i have a item switcher i have made in php and java script but for some reason it works in google chrome but not in firefox. The switcher lets the user pick 1 item and make it there active item so they can do things with it.
I've inherited a page that enters data into a database, some of the fields are calculated and one uses today's date. In Firefox it all works fine but in IE it wont load the full page.