Why does this JavaScript work on Safari, but not on Firefox?

I have an HTML file. I tried the code in Safari and it worked fine. But when I tried this on Firefox, it didn't work. Can anyone suggest how to make it work with firefox?

When I click the cancel button, I want to get the contents from the jsp file. This works when I used this safari code on my mac .. but when I open the same file using firefox, it does not work. I'm not sure if this is due to browser settings or for some other reason. I checked the firefox 3.6.12 browser setting installed on mac and it is enabled for javascript and java ...

When I checked HTTPfox, it showed in Error loading content (NS_ERROR_DOCUMENT_NOT_CACHED) in the content

Can anyone suggest what is going wrong?

+4
source share
5 answers

XMLHttpRequests only works when the request is in the same domain as the JavaScript that creates the request. That way, your xmlHttp.open() call will only work if this HTML file is hosted on csce.unl.edu .

+6
source

Can the ubuntu window access the URL http://csce.unl.edu:8080 ? This can be the network / proxy / firewall settings in the virtual machine or in Firefox settings.

+2
source

I would try running firefox on Mac and see what it makes me. If this does not work, then the problem is with the browser, if so, how do you load the site

+2
source

Use jQuery . It has an AJAX library that checks compatibility with you.

In addition, Firebug can come in handy to find out if a request is being sent and how to respond.

+1
source

I opened firebug console> and inserted

 var xmlHttp, handleRequestStateChange; handleRequestStateChange = function() {if (xmlHttp.readyState==4 && xmlHttp.status==200) { var substring=xmlHttp.responseText; alert(substring); } } xmlHttp = new XMLHttpRequest(); xmlHttp.open("GET", "http://csce.unl.edu:8080/test/index.jsp?id=c6c684d9cc99476a7e7e853d77540ceb", true); xmlHttp.onreadystatechange = handleRequestStateChange; xmlHttp.send(null); 

And I saw that everything works. What error exactly? Can you open firebug and look at javascript errors.

Edit:

  var req = new XMLHttpRequest(); req.open('GET', '/'); req.onreadystatechange = function (aEvt) { if (req.readyState == 4) { if(req.status == 200) alert(req.responseText); else alert("Error loading page\n"); } }; req.send(null); 
+1
source

All Articles