| Author |
how to insert data to a mysql table using ajax (client side)
|
nastaran zanjnai
Ranch Hand
Joined: Apr 15, 2011
Posts: 43
|
|
can you please let me know how to insert data to a mysql table from client side using ajax. the client generates the data. this data should be stored in the database.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56218
|
|
|
Send the data back to the server in a request same as any other request. The server doesn't even know what Ajax is, so you don't do anything different.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
nastaran zanjnai
Ranch Hand
Joined: Apr 15, 2011
Posts: 43
|
|
I am suing the following code in a JS file
and the following code in the php file
but when I check the data base there is noting written in the table.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56218
|
|
|
Have you checked the request to make sure that it contains the data you expect? And, a GET isn't an appropriate method; should be a POST.
|
 |
nastaran zanjnai
Ranch Hand
Joined: Apr 15, 2011
Posts: 43
|
|
sorry, do you mean that I should change all GETs to POST. is this a correct one?
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56218
|
|
At a high level, GETs are for getting data without changing anything. POSTs are for making changes.
|
 |
nastaran zanjnai
Ranch Hand
Joined: Apr 15, 2011
Posts: 43
|
|
|
solved.
|
 |
 |
|
|
subject: how to insert data to a mysql table using ajax (client side)
|
|
|