Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think I've found the problem (skip to the bold text for the short answer).</p> <p>I tried the example on my machine by creating an .html file on my desktop and uploading the PHP snippet to my dev server on the LAN. This gave me the exact same results as you, also with Firefox (v3.5.7).</p> <p>I'm not a PHP guy (more Python / Django) but I do know some basic PHP and your code looked fine to me. I confirmed this with much Googling of PHP / JSON / Ajax example-seeking. I tried every option given in advice forums, including various caching header options in the PHP and different JQuery methods, including changing some of its cache options and also trying various different options. No difference.</p> <p>I completely simplified the PHP to literally just return a single-item JSON array, without any other conditionals or control structures - no joy.</p> <p>Eventually I got desperate and tried the same file in IE 8. It worked! Tried it in Safari - it worked!</p> <p>I then got paranoid and thought there might be some sticky session issues in Firefox or some other oddity so I completely cleared my Firefox history and restarted the browser. No difference.</p> <p>This at least gave me a different angle on what I could Google for to see if others had the same problem. Indeed they had.</p> <p>It turns out that <strong>if you are running the HTML file containing the Ajax on your local machine, i.e. with a "file://" prefix, Firefox for some reason will not make the Ajax calls correctly.</strong> I copied the file up to my dev server, in the same location as the PHP file (but still using the full address as the Ajax URL) and sure enough it worked!</p> <p>I don't fully understand what Firefox does differently with truly local files and Ajax, but it's getting light outside and I can't investigate right now. I did look through the settings regarding security but nothing obvious jumped out at me. I'd be very interested to know how this fits into how your dev environment is set up. I will investigate further later if I get a chance and will update this answer.</p> <p>I wouldn't be surprised if there is some or other option in "about:config" that may contain the answer.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload