PDA

View Full Version : AJAX using JQUERY



wotupduck
24 Mar 2011, 06:40 AM
I am currently building a room booking web application for a school (as a school project) i currently have a index page with a div as follows:


<div id="page_content">

</div>

this area of the page is used to load in external php pages with generate contnent for a database i am currently using jquery to load the content in:


$('#Rooms').click(function(){
$('#page_content').load('rooms.php');
});

within the rooms.php file there is a jquery datepicker the problem i am having is making the datepicker work once it is loaded into the page content area of the index page. i have tryed including

<script>
$(function() {
$( "#datepicker" ).datepicker();
});
</script>
as well as the required jquery ui scirpts that need importing in the rooms.php and index.php files aswell as putting the above code in the $(document).ready wrapper but i have had no luck making it work can anyone help? thanks in advance.

coiner
24 Mar 2011, 06:01 PM
You need to specify an AJAX call with jQuery in order to retrieve content.



$.ajax({
type: "GET",
async: true,
url: "whatever.php",
success: function (data) {
//Do what you will with the output stored in 'data'
}
});


There is a ton more functionality for this, but this is the basic syntax for an AJAX call with jQuery.