Answer the question
In order to leave comments, you need to log in
How to get parameters when parsing url (php, mvc, ajax)?
There is an app.php file Shortened
version...
class App
{
protected $controller = 'Main_controller';
protected $method = 'index';
protected $params = [];
const SITE_PATH = '/mysiteru/public/';
public function __construct (){
$url = $this->parseUrl();
unset($url[0]);
unset($url[1]); (убираю контроллер и метод базовый)
$this->params = $url ? array_values($url) : [];
// BASE::print_data($this->params);
call_user_func_array([$this->controller,$this->method],$this->params);
}
public function parseUrl (){
if(isset($_GET['url']))
{
return $url=explode('/',filter_var(rtrim($_GET['url'],'/'),FILTER_SANITIZE_URL));
}
}
}
$('form').on('change','select',function(){
$.ajax({
type: "POST",
url: "/mysiteru/public/mo_search/chained/5/need/",
dataType: "json",
success: function(data, textStatus) {
console.log(data);
}
}); /// КОНЕЦ AJAX
});
public function chained($params)
{
$url=App::parseUrl(); //работает
$url=App::$this->params; // не работает..
}
Answer the question
In order to leave comments, you need to log in
And why not do this: ajax calls you with such an address sample/search we
launch the sample controller and call the search method, which either processes the POST itself (which is not very good), or passes it to the model that checks the POST data and does its dirty deeds with them
For example, I have a POST data check based on the fact that a specific one is accessed, like this, for example, Requst::checkVarPost('search','string');
why not use only POST for such things?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question