Is there a way to send data to database when click on a link without page refresh?
I use php/mysql…
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I will give you an example using jQuery.
Let’s say that we have a link with an attribute id=”button_id” (you have to learn the jQuery selectors ).
Explanation: you will send the variable
var_datawith the namevar_PHP_datato amy_script.phpwithout page refresh using an ajax call (using GET method).This is very simple example of what you have to write on your PHP script.
?>
Because the default method to send variables in the
ajax function in jQuery is GET.We have to use the $_GET function in PHP.
This php script will print a message and this message will be handled in the
success: functionin the Ajax call and just for example we will alert this message returned from PHP.