Home >Backend Development >PHP Tutorial >post - Thinkphp I method to obtain variables?
I have been using thinkPHP’s I method
to get the data from js ajax. The I method
can receive the data passed by the post or get method, but today when receiving the array passed by js (use JSON.stringify
conversion) into a string), the data cannot be received using the I method
, but other data can be received normally, and the data can be received normally using the $_POST[]
method. What is the situation?
I have been using thinkPHP’s I method
to get the data from js ajax. The I method
can receive the data passed by the post or get method, but today when receiving the array passed by js (use JSON.stringify
conversion into a string), the data cannot be received using the I method
, but other data can be received normally, and the data can be received normally using the $_POST[]
method. What is the situation?
I('post.data','','strip_tags');
Try filtering it
Try adding the filter parameters of the I method! For example, the json
string you want to receive plus htmlspecialchars
or strip_tags
<code>//试试看能不能接收到 I('json', '', 'htmlspecialchars'); I('json', '', 'strip_tags');</code>
I method will identify the data type of ajax. If the data type is get, then the default parameter of the I method is get.