1

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

Dave Melia
  • 307
  • 2
  • 5
  • 17

3 Answers3

3

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');
Mkdgs
  • 167
  • 2
  • 11
2

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.
Nibin
  • 3,922
  • 2
  • 20
  • 38
0

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.

tea2code
  • 1,007
  • 1
  • 8
  • 15
  • 1
    Thx. Didn't know there is a difference but this explains it quite nice: http://stackoverflow.com/questions/7062775/is-jquery-a-javascript-library-or-framework – tea2code Sep 06 '13 at 11:07