Anish Sharma
Anish Sharma

Reputation: 334

Sending AJAX request doesn't work on all pages

I have created a search box where when I click the search button, an ajax request is send to a page search.php which does its work and returns the search results.

My code has this line. I have placed this in the header file so it works on all pages -

xhttp.open("GET", "search.php?q="+q); //q is the requested search string
xhttp.send();

It works good in the root directory(public_html) but in a sub-directory, it doesn't (I know it won't). So, I edited the code -

xhttp.open("GET", "http://www.theorembox.esy.es/search.php?q="+q); //q is the requested search string
xhttp.send();

But now it even doesn't work in the root directory. What should I do??

Can anyone help me in this.

Thanks

Upvotes: 0

Views: 66

Answers (1)

Jignesh Patel
Jignesh Patel

Reputation: 1022

Try this.

xhttp.open("GET", "/search.php?q="+q);

Upvotes: 1

Related Questions