• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Validating Ajax Put Request

#1
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.
Reply

#2
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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

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

#4
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...quest.html
Reply

#5
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.
Reply

#6
(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?
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.