1

This is really strange... I receive this error in the console everytime I enter in the product details of some products (not all):

"xmlhttprequest cannot load no 'access-control-allow-origin'"

Here's an image:

enter image description here

I have tried to fix it adding to the htaccess file the next code:

Header set Access-Control-Allow-Origin "*"

But it didn't work... Can anyone help me? I need help real fast... JQuery doesn't work in that part of the page because of that error...

2

The reason you are getting this message is stated in your image- you are trying to access http://benaventegrow.com from the website http://www.benaventegrow.com They look similar, but they are not the same. So why is this a problem?

JavaScript code is limited by the same-origin policy, meaning, from a page at www.example.com, you can only make (AJAX) requests to services located at exactly the same domain, in that case, exactly www.example.com (not example.com - without the www - or whatever.example.com).

The link below explains what is going on much better than I can and is the source for the quote above. https://stackoverflow.com/a/20434788/691053

How to fix?

Disclaimer: I've never used virtuemart before- but what I would do is check the product entries in virtuemart for the products that give you the error. Check that the product entries contain www in the link. Example -> http://www.benaventegrow.com if they don't have it then add it.

Also it is a bad idea to use Header set Access-Control-Allow-Origin "*"

By responding with Access-Control-Allow-Origin: * the requested resource allows sharing with every origin. This basically means that any site can send a XHR request to your site and access the server’s response which would not be the case if you hadn’t implemented this CORS response.

This is explained in more detail here https://stackoverflow.com/a/12014554/691053 and it is the source of the quote above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.