I call ajax in my script using jquery. For this, I created a separate controller (AjaxController) and in it a certain actionRequest method. jQuery passes a post request there:
jQuery.ajax({ url: location.origin + '/ajax/request', async: false, type: 'POST', data: {'params': params},//масив dataType: 'json', success: function(data) {result = data} }); in the script itself is such code:
$params = Yii::$app->request->get('params') echo $params; The problem is that the post-requests to get to the server reluctantly. get going fine, but changing to post- nothing comes. With that I make a request to my script (just pkhp script is not tied to the engine)) - everything goes fine ....
ps I do not know yet how to interpret all this. I add the following actions to the action code:
$root = $_SERVER['DOCUMENT_ROOT']; $file = fopen($root . '/text.txt', 'w'); fwrite($file, '1'); fclose($file); If I transfer a get request, the file in the root of the site is created. if I pass the post, I don’t even want to create the file. It feels like it is interrupted somewhere much earlier and when sending a post request, even my code does not execute ...
success? and inparamsare you sure something is being transmitted? - Alexey Shimanskyajaxtotype: 'POST',do you remember to write a post inphptoo?Yii::$app->request->post('params'). Show me yourparamsarray just in case - Alexey Shimansky