Javascript works in Safari but not in Chrome or Firefox

I am not a programmer at all, so I apologize in advance, but after searching the Internet I can not find the answer.

I am trying to search for inventory from this website and put it on the Facebook tab. I grabbed the code from the website and edited the headers and footers that I didn't want in TextEdit. I am only trying to take the inventory search part.

When I tested it in Safari, it worked. The inventory search began, and all the buttons and filters worked fine, and when I go to another page, the headers and footers still disappeared, and only the inventory search was there - great.

However, when testing in Chrome and Firefox, the buttons and filters did not work at all, and you cannot go past the first page or apply filters.

So, I decided to go to the site (the first page of the inventory search, for example, the link above) and save the source code on my desktop to find out if it will open in Chrome or Firefox if it works and it didn’t work, the buttons filters did not work, stuck on the first page. But he worked at Safari.

What does it mean? Should I give up now? I would have included the code, but this is the longest I've ever seen. All the code tests that I have done using TextEdit.

edit :
Here are the errors in Chrome:

Uncaught SyntaxError: Unexpected token <Chevy.html: 4608 XMLHttpRequest cannot load http://www.erikschevrolet.com/searchVehicles.ajax . The origin of null is not allowed by Access-Control-Allow-Origin.
Error opening: XmlRenderEngine => Unknown error bundle.js: 1 XMLHttpRequest could not load http://www.erikschevrolet.com/searchVehicles.ajax . The origin of null is not allowed by Access-Control-Allow-Origin.
Error opening: XmlRenderEngine => Unknown error bundle.js: 1 XMLHttpRequest could not load http://www.erikschevrolet.com/searchVehicles.ajax . The origin of null is not allowed by Access-Control-Allow-Origin.
Error opening: XmlRenderEngine => Unknown bundle.js error: 1

+7
source share
2 answers

These Chrome warnings are not relevant here. The errors listed above relate to cross-origin issues. Because of the really evil things that make it possible to access remote resources from Javascript, modern browsers block them if they are not explicitly allowed.

For example, most of the content from http://example.com is not available for javascript under http://example.net . Since you downloaded most of the files and you try to run them locally, but still some of them relate to files in the domain http://www.erikschevrolet.com , this is not allowed.

AFAIK there is really no easy way to avoid this problem; a safe solution will allow you to download all the files used and manually change the links to http://www.erikschevrolet.com with links to your local path. Alternatively, you can set the withCredentials value for XMLHttpRequest to true (but since you are not a programmer, you can really mess it up ...), like this (example from http://hacks.mozilla.org/2009/07/cross-site -xmlhttprequest-with-cors / ):

var request = new XMLHttpRequest(); var url = 'http://bar.other/resources/credentialed-content/'; function callOtherDomain(){ if(request) { request.open('GET', url, true); request.withCredentials = "true"; request.onreadystatechange = handler; request.send(); } } 

And even this may not get the expected result, since many of these files are probably generated dynamically on the server and can be changed.

+1
source

It seems that you have a problem reading xml or text files in javascript with a specific loading file scheme. this happens in browsers where http requests work, here in this case you can try something like working in javascript,

 if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } 

this will work on firefox hrome safari and also try this.

0
source

All Articles