aspose file tools
The moose likes HTML, CSS and JavaScript and the fly likes how to insert data to a mysql table using ajax (client side) Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "how to insert data to a mysql table using ajax (client side)" Watch "how to insert data to a mysql table using ajax (client side)" New topic
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
    
  13

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
    
  13

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
    
  13

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to insert data to a mysql table using ajax (client side)
 
Similar Threads
XML to database
Encoding and Decoding
Double byte characters in Ajax.
hibernate+spring+mysql+tomcat
Refresh jstl table with javascript