CodeIgniter Forums
Validating Ajax Put Request - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Validating Ajax Put Request (/showthread.php?tid=74985)



Validating Ajax Put Request - engel - 12-04-2019

Hi,

If I am tying to validate data coming from AJAX PUT request, can this code
PHP Code:
$validation->withRequest($this->request)->run(); 
 validate those data? Thanks.


RE: Validating Ajax Put Request - InsiteFX - 12-04-2019

The Ajax validation should be in the JavaScript code.

Transferring data should be done using Json format.

If the Ajax put is sending Json and it's an Json array you can use json_decode()
on it then use php to validate the data.


RE: Validating Ajax Put Request - engel - 12-04-2019

That is exactly what I am about to do. Make my own validation for ajax requests. Thanks.


RE: Validating Ajax Put Request - naghtigall - 03-10-2020

In Codeigniter 4 you can check data was sent from form or from ajax request and strong check POST or GET method.
Some link in documentation: 
https://codeigniter4.github.io/userguide/general/ajax.html
https://codeigniter4.github.io/userguide/incoming/incomingrequest.html


RE: Validating Ajax Put Request - kilishan - 03-10-2020

The validation helper only works with information that would be in the $_REQUEST global. PUT requests don't work that way, so yes, you would need to pull out your json/xml and validate manually through the validator.


RE: Validating Ajax Put Request - nicojmb - 04-22-2020

(12-04-2019, 09:54 AM)engel Wrote: That is exactly what I am about to do. Make my own validation for ajax requests. Thanks.

Hi engel, how do to solve this problem? Can you share me your solution/fix?