jquery - Defining $_POST variable when using single point entry PHP -


i built single point entry controller in php (all routing through index.php). works great im having issue setting $_post variable ajax call.

i'm guessing because url of ajax call /submit , not /index.php

$url_page page name browser url. handeld in function im leaving out of example

switch($url_page) { case '':   echo 'when login works redirect to correct page'; break;  case 'admin':     $template_page->set_values('url', url);     $template_page->set_values('path', path);     $template_page->set_values('navigation', '');     $template_page->set_values('sidenavigation', '');     $template_page->pagecontet('admin.html');     echo $template_page->build_template(); break;        case 'student':     $template_page->set_values('url', url);     $template_page->set_values('path', path);     $template_page->set_values('incjs', url.'/assets/js/studentjs.js');     $template_page->set_values('navigation', file_get_contents(templates.'/studentnav.html'));     $template_page->set_values('sidenavigation', file_get_contents(templates.'/usersidenav.html'));     $template_page->pagecontet('students.html');         echo $template_page->build_template(); break;  case 'submit':   cannot access $_post here  break;  default:     header('location:'.url.'/404.html') ;           break; } 

and here ajax

$('.navicagtionclass > li > a').click(function() {  var page = $(this).attr('value'); var obj = {}; obj['page'] = page;  $.ajax({         url: "/submit",         type: "post",         data: obj,         datatype: "json",         success: function(data) {             console.log(data);           document.getelementbyid('pagecontent').innerhtml = data.a;         },         error: function(xhr, status, err) {           console.log(err);         }   }); 

});

if correctly understand approach, cannot use page on ajax processor file. need separate php file process ajax , return index.php.

in source referenced below, note example prefixed "try , you'll see mean" -- give try.

source:

values not updated after ajax response


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -