tags:

views:

437

answers:

3

Is it possible, and how can I go about this?

+3  A: 

Yes, but with ajax help and server side script. jquery and JS doesn't support MySQL connection.

Thinker
+2  A: 

Not directly but you can use Ajax to fetch content from a page generated by a server side language. Here is how to use Ajax with jQuery.

Sam152
+2  A: 

Short answer:

No, you can't do that out of the box. JavaScript code runs in the browser, the MySQL-Database on the server. Browser-Javascript cannot run any code directly on the server (pfewww! :).

Long answer:

Some Web-Development-Frameworks expose the underlying database-structure in a well-defined (sometimes RESTful) manner in json:

In case of a hypothetical model 'User' in Ruby on Rails:

The list of all users, when issued as GET request. Creates a new User, when issued as POST.

/users.json

Returns the User with the database-id 1, when issued as GET request. Updates the User with database-id 1 when issued as PUT-Request. Removes the object when issued as DELETE request.

/users/1.json

The returned json-code (JavaScript Object Notation) can easily be parsed using eval() in JavaScript. So here's a way to access your database using jQuery in semi-direct way :)

Hope this helps

flitzwald