Running XMLHttpRequest in Firefox gives no results at all
-
* Using Firefox v43. * Trying example at Simple and Practical Introduction to Asynchronous JavaScript and XML (AJAX)[^] * I'm a newbie here and with Javascript. If this isn't the right site for newbies just let me know. Some sites are somewhat hostile to newbies. * I do have Ublock Origin in FF, I don't know if that or FF is blocking popups or not. If so, how do I get FF to not block popups from local HTM files? I made the XML file and html file (which I called ajax1.htm) and opened it in Firefox. I clicked the button "ReadXML" and it did nothing, nothing changed in my browser. I'm trying to figure out if FF does not support XMLHttpRequest or if something else is going on. Do you have any ideas? EDIT: The bottom of ajax1.htm has been changed to this to test the Error() function via clicking a new button. I got no result from clicking the "Test error" button either. (The code formatting does not seem to be working.)
</script>
<script type="text/javascript">
function testButton() {
Error("This is an error");
}</script>
<body>
<span id="xmlSpan"></span>
<input type="button" onclick="ReadXmlFile();" value="ReadXml" />
<input type="button" onclick="testButton();" value="Test Error" /> -
* Using Firefox v43. * Trying example at Simple and Practical Introduction to Asynchronous JavaScript and XML (AJAX)[^] * I'm a newbie here and with Javascript. If this isn't the right site for newbies just let me know. Some sites are somewhat hostile to newbies. * I do have Ublock Origin in FF, I don't know if that or FF is blocking popups or not. If so, how do I get FF to not block popups from local HTM files? I made the XML file and html file (which I called ajax1.htm) and opened it in Firefox. I clicked the button "ReadXML" and it did nothing, nothing changed in my browser. I'm trying to figure out if FF does not support XMLHttpRequest or if something else is going on. Do you have any ideas? EDIT: The bottom of ajax1.htm has been changed to this to test the Error() function via clicking a new button. I got no result from clicking the "Test error" button either. (The code formatting does not seem to be working.)
</script>
<script type="text/javascript">
function testButton() {
Error("This is an error");
}</script>
<body>
<span id="xmlSpan"></span>
<input type="button" onclick="ReadXmlFile();" value="ReadXml" />
<input type="button" onclick="testButton();" value="Test Error" />1. The link you posted is to an article. Usually if you have a question about the article you post it at the bottom of the article. In this case I think it's still valid that you asked here. 2. Notice the date on that article, 2009. Quite old in tech years. I suggest using jQuery and calling .ajax() instead. There are tons of examples online and jQuery is a library that keeps up with the various browsers so the same code should work in all browsers. 3. See jQuery.ajax() | jQuery API Documentation[^] for documentation. 4. Also, if you choose to stick with your original question, edit it and post the relevant code.
There are only 10 types of people in the world, those who understand binary and those who don't.
-
* Using Firefox v43. * Trying example at Simple and Practical Introduction to Asynchronous JavaScript and XML (AJAX)[^] * I'm a newbie here and with Javascript. If this isn't the right site for newbies just let me know. Some sites are somewhat hostile to newbies. * I do have Ublock Origin in FF, I don't know if that or FF is blocking popups or not. If so, how do I get FF to not block popups from local HTM files? I made the XML file and html file (which I called ajax1.htm) and opened it in Firefox. I clicked the button "ReadXML" and it did nothing, nothing changed in my browser. I'm trying to figure out if FF does not support XMLHttpRequest or if something else is going on. Do you have any ideas? EDIT: The bottom of ajax1.htm has been changed to this to test the Error() function via clicking a new button. I got no result from clicking the "Test error" button either. (The code formatting does not seem to be working.)
</script>
<script type="text/javascript">
function testButton() {
Error("This is an error");
}</script>
<body>
<span id="xmlSpan"></span>
<input type="button" onclick="ReadXmlFile();" value="ReadXml" />
<input type="button" onclick="testButton();" value="Test Error" />When you have a question about code in an article, it's usually best to post it in the forum at the bottom of the article[^]. That way, the author will be notified of your question and have a chance to respond. The person who wrote the code is the person most likely to be able to answer your question. :) Are you loading the page from a web site, or just double-clicking on the HTML file in Windows Explorer? You might have problems making AJAX requests work in a local file. Have you tried checking the Web Console[^] (F12) for error messages? Firefox definitely supports the
XMLHttpRequest
: XMLHttpRequest[^] Can I use... XMLHttpRequest advanced features[^]Error
isn't a built-in function, and doesn't appear to be defined in the article's code. Try usingalert
instead:function testButton() {
alert("This is an error");
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
When you have a question about code in an article, it's usually best to post it in the forum at the bottom of the article[^]. That way, the author will be notified of your question and have a chance to respond. The person who wrote the code is the person most likely to be able to answer your question. :) Are you loading the page from a web site, or just double-clicking on the HTML file in Windows Explorer? You might have problems making AJAX requests work in a local file. Have you tried checking the Web Console[^] (F12) for error messages? Firefox definitely supports the
XMLHttpRequest
: XMLHttpRequest[^] Can I use... XMLHttpRequest advanced features[^]Error
isn't a built-in function, and doesn't appear to be defined in the article's code. Try usingalert
instead:function testButton() {
alert("This is an error");
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
I'm opening a local HTML file. And I didn't know Error() wasn't a standard function. So I'll look into that. Thanks. If I put the html file on a web server (I have an account on sdf.org) will Ajax work then? That sounds like a PITA if Ajax won't work in a local file.
-
I'm opening a local HTML file. And I didn't know Error() wasn't a standard function. So I'll look into that. Thanks. If I put the html file on a web server (I have an account on sdf.org) will Ajax work then? That sounds like a PITA if Ajax won't work in a local file.
I'm not certain that it won't work from a local file; I've just seen a few issues crop up with local files that are resolved by using a web server. You don't need a live server to deploy it. You can use a local instance of IIS, or create a project in Visual Studio and use IIS Express. If you haven't got a copy of Visual Studio, you can get Community Edition for free: Free Dev Tools - Visual Studio Community 2015[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
I'm not certain that it won't work from a local file; I've just seen a few issues crop up with local files that are resolved by using a web server. You don't need a live server to deploy it. You can use a local instance of IIS, or create a project in Visual Studio and use IIS Express. If you haven't got a copy of Visual Studio, you can get Community Edition for free: Free Dev Tools - Visual Studio Community 2015[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Sorry. I'm new here.