How do I use Ajax and Jquery to pull information off a PHP database, and populate elements with that information?

Ajax cannot access your database. Ajax simply loads content from a URL. Your application must do this, and provide the result to an ajax call.

Ajax cannot access your database. Ajax simply loads content from a URL. Your application must do this, and provide the result to an ajax call.

Here's how it will work. Browser open a url on your server PHP renders a page for display on the browser User clicks something Javascript sends an Ajax request to your server PHP recieves this request and queries the database PHP renders a response for the request The Ajax handler on your page receives this response as plain text and does something interesting with it (such an inserting HTML, evaluating JSON, or executing javascript) Ajax is just a way to load the response from a URL without actually navigating your browser to that page. It does not (and should not) have any sort of direct database access.In fact it has no idea there is a database at all.

Imagine the security issues if any javascript could read or write any field in your database. It would be a hackers dream.

– Jared Feb 2 '10 at 20:44 Just updated with some more info of the steps involved. The ajax part is pretty easy. But definitely need the PHP side of things to get a proper response for the ajax query.

– Squeegy Feb 2 '10 at 20:48.

You have to write a PHP script that queries the database and returns the results either as JSON or HTML. This script is called via jQuery. E.g.

$('#main'). Load('your-url.com/yourscript.php'); This loads the output generated by yourscript. Php (given that it is HTML) into an element with ID main.

You can find an Ajax tutorial with jQuery here. And a lot more tutorials on the jQuery tutorials site.

Alright, that will get me started, Thanks! – Jared Feb 2 '10 at 20:47.

PHP - actually, it seems to be no job for jquery - once somebody edits it in DB, app gets latest information every hit. Unless I misinterpreted your question, I see nothing this has to do with jQuery/AJAX.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions