Home  >  Article  >  Backend Development  >  post - Thinkphp I method to obtain variables?

post - Thinkphp I method to obtain variables?

WBOY
WBOYOriginal
2016-08-25 10:37:191012browse

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.stringifyconversion) 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?

Reply content:

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.stringifyconversion 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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn