In the laravel5.5 / jquery 3.2 application, a request is made to the server

$.ajax({ url: url, method: 'delete', headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, success: function(res) { ... 

and in case of a successful return, you need to go to another page but with a number of parameters I don’t want to display the parameters in the URL, so

 document.location= '/url?param=1' 

not like

How easy is it to simulate a POST request?

MODIFIED:

1) yes and accept the request in laravel-control-e. It seems that in such cases they draw a separate form with invisible (hidden) elements action = "POST" and generate a submit for it. Maybe there is something better?

2) laravel-control is called in the js-slice:

 public function checkOutStorageSpace($id) { app('StorageSpaceSer')->checkOutStorageSpaceById($id); return response()->json(['message' => 'Successfully']); } 

Is it possible to send a POST request with parameters to another URL from this control, and if so, how? And will not the earth strike the heavenly axis from such a programming?

  • To simulate from html-code? Or in the form of get-parameters for reception in a php-file? - MAX
  • Look at the MODIFIED block - mstdmstd
  • I’ll not say anything about laravel (I’m not working with him), but if it were a simple php file that receives a post request, then you can receive get requests for the duration of the test. Essentially, the $ _POST and $ _GET arrays are the same, so you can look for the presence of a get request and, if there is one, use it. If not, use post data. This will allow you to test via a direct url call with the desired get parameters. - MAX

1 answer 1

Try this

 $.post( "test.php", { name: "John", time: "2pm" } ); 
  • I tried. But I need not send ajax POST request, but submit the whole page. - mstdmstd
  • what do you mean? - Mikola Mirchuk