Jquery load() only working in firefox?
Try launching chrome / chromium with --allow-file-access-from-files
flag set
See How do I make the Google Chrome flag "--allow-file-access-from-files" permanent?
why Jquery load is not working in firefox?
Assuming you are opening this from the local filesystem and you open the devtools console - you are going to see an error like this
Access to XMLHttpRequest at '<yourfolder>/nav.html' from origin
'null' has been blocked by CORS policy: Cross origin
requests are only supported for protocol schemes:
http, data, chrome, chrome-extension, https.
This means you are running into a CORS issue - which you can read more about here
To make this work serve it using a simple http server - I would suggest something like serve - https://www.npmjs.com/package/serve
If you are already using an http server, post the console errors.
Best of luck!
jquery/ajax code don't work on firefox but on other browser works
add the e parameter to the click event, then it will work.
click(function (e) {
Also: you should care about error handling.
var jqxhr = $.ajax( "example.php" )
.done(function() {
alert( "success" );
})
.fail(function() {
alert( "error" );
})
.always(function() {
alert( "complete" );
});
jquery-issue with load(): works with Firefox and Safari, not with Chrome, Opera and IE
adeneo gave the hint: The script is fine, but I "can't make ajax requests from a file:: protocol". I tried to load the file from a local folder. Obviously the 3 browsers don't like it... and Firefox and Safari just ignore it.
jquery Firefox doesn't fire window.onload
it works now fine when I used
$( window ).load(function() {
thanks all for efforts.
Why jQuery is working when directly opened as file on firefox but not working in XAMPP server?
It is important to note that document.ready
has already occurred in the main page.
Any script inside the newly loaded pages that relies on document.ready
will fire immediately.
If that script is placed before the elements that it targets , the elements won't be found. Moving the script to the end of the newPage.html
so it runs after those elements exist will make it work.
Example of newPage.html that will fail once it is loaded:
<script>
$(document).ready(function(){
// will run before the element below exists
$('#test').text('Some new text');
})
</script>
<div id="test"></div>
But reversing the order will make it work:
<div id="test"></div>
<script>
$(document).ready(function(){
// element above exists so text will be changed in it
$('#test').text('Some new text');
})
</script>
Related Topics
How to Check Whether a Checkbox Is Checked in Jquery
JavaScript Code to Stop Form Submission
Retrieve the Position (X,Y) of an HTML Element
Why Isn't My JavaScript Working in Jsfiddle
Difference Between Properties and Attributes in Html
Get the Size of the Screen, Current Web Page and Browser Window
In JavaScript How to Make a "Click" Event Fire Programmatically For a File Input Element
Invoking JavaScript Code in an Iframe from the Parent Page
Capture HTML Canvas as Gif/Jpg/Png/Pdf
Communication Between Tabs or Windows
Why Calling Setstate Method Doesn't Mutate the State Immediately
Why Can't I Call a Function Named Clear from an Onclick Attribute
Offsetting an HTML Anchor to Adjust For Fixed Header
How to Get the Data-Id Attribute
How to Read CSS Rule Values With JavaScript
How to Pick Element Inside Iframe Using Document.Getelementbyid