Sorry but I really have to ask. I have been trying this AJAX for hours! Please go to this link.. http://www.w3schools.com/ajax/tryit.asp?filename=tryajax_first I copied all the codes on the left hand side and saved it into a new html file called a.html. Then I opened it with my Chrome/Firefox. I can see a line of text and a button but when I click on the button, it does nothing. Please tell me why.
You need to run it on a webserver? Or you are trying to fetch data from a file that is not there (ajax_info.txt) ?
I need the AJAX in my webserver but now I'm trying it with my pc alone first. I try to fetch the text file which is exist. Do I have to put them into a server to work?
This is my code. I tried it in WAMP and everything is working fine. It is able for me to fetch the like.php and execute properly. After I have uploaded this code to my webserver and I tried to do the same thing, it is not working. When I click on the image, it gives me no response. Meaning to say that, there must be something wrong with my ajax and it does not fetch the like.php file.
Yes I did. I tried to run this in WAMP server and it works fine but when I try to run it in webserver, it is not working. FYI, all files in webserver and in WAMP is exactly the same. Btw.. The file contains the JavaScript and HTML above is a php file. Will this affect anything I wonder?
I really can't see a problem with the javascript, although maybe im missing something... try loading like.php with some random args within your browser and see what it returns.. maybe the problem is with the php...
or maybe your $id var is not returning what you expected... try displaying that also just to eliminate that as a problem...
Everything is working fine except the javascript, this is what I'm suspecting. The like.php file loads fine and the $id returns a value too. I'm not sure what is going on here.. Seriously I tried it WAMP, it works great but not in here.
Sorry for the confusion caused. Initially the function name is called likepage() and I copied the wrong file, very sorry.
There is nothing wrong with your javascript, it should work fine. The problem must be occurring somewhere with the file that it is trying to retrieve.