Hello , so i get an error with ajax when i move the site i scripted to my server ( so on my localhost it works ) . The error is something like origin not allowed by access control allow origin

var trimitere = $.ajax({
                url: "underpublic/searchforprice.php",
                type: "get",
                crossDomain: true,
                data: coduri + '&callback=?',
                success: function(response) {
                    if(response != ''){
                        $(".loader").hide(500);
                        $("#aratarez").append(response);
                    }else{
                        $("#rezultate").hide(400, function(){
                            alert("fail");
                        }); // end functie hide

                    } // end if-else
                } // end succes

            }); // end ajax

Recommended Answers

All 8 Replies

Member Avatar for LastMitch

The error is something like origin not allowed by access control allow origin

@MWEB

You need to check whether your path to that file is there.

@LastMitch can you be more explicit ? please :D

does underpublic/searchforprice.php exists on your server?

More explicitly www.yourwebsite.com/underpublic/searchforprice.php

What happens if you take the crossDomain: true line out?

So , if i remove crossDomain: true ->

XMLHttpRequest cannot load http://www.url.ro/. Origin http://url.ro is not allowed by Access-Control-Allow-Origin. 

Yes , the path exists

..and is your script running off www.url.ro/underpublic/searchforprice.php ?

Thank's , Solved !!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.