Programatically create a page with AJAX

Permalink
Hey folks,

As the title suggests I'm trying to Programatically create a page with AJAX.

Tried the method where you just use jquery $.ajax as shown below, but then how do I send the page object to the php file? (relevant code is in ajaxtest.php).

$('.sub-entry-form form').submit(function(){          
         $.ajax({
            type: "POST",
            url: "/themes/project/includes/ajaxtest.php",
            data: $(this).serialize(),                      
            success: function(data){
              console.log(data);
            },
            error: function(){
              console.log('error');
            }
          });
          return false;
        });


From other threads, it looks like I have to do this using the page type controller in a view function, though not really sure how to proceed (I'm pretty new to MVC). How would I trigger the php code in the view function? With the form action?

Thanks,
Joe