3

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

1
  • 1
    What about writing a decent summary/title for the question ? Commented May 23, 2009 at 10:38

3 Answers 3

3

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

Sign up to request clarification or add additional context in comments.

Comments

2

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.

Comments

2

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.