I'm not entirely familiar with the MVC model and I cannot get my head around it, however I am trying to simplify things by having my page design separate from my logic. I have my basic template all set up, and I would like hyperlinks to open PHP files within the same page.
For instance:
Next Page
rather than opening nextpage.php, I would like the contents of nextpage.php to open the code into a div on the same page. The contents of nextpage.php will contain some PHP code, and some HTML forms
I'm assuming AJAX is the right approach to this, but any suggestions is greatly appreciated.
Thanks
take a look to: http://api.jquery.com/load/
you can load only on part of a page in a html element
$('#result').load('ajax/test.html #container');
I would use a framwork like jQuery and use the ajax() function. Then you must simple execute the statement and in the success handler set content of the div to the received data.
Ajax function
$(document).ready(function(){
$("#submitBtn").click(function() {
$.ajax({
type: "POST",
url: "request.php", //Your required php page
data: "id="+ studentid, //pass your required data here
success: function(response){
$('#output').html(response);
}
});
return false;
});
});
request.php
<?php
$student_id= $_POST['id']; //The data that is passed from tha ajax function
$message = "The id you have entered is".$student_id;
echo $message;//This will be obtained in the ajax response.