Use Json.stringify () in the JQ code in the foreground to convert the array to a JSON string, and Json_decode () in the background to convert the JSON string into a group.
1,json.stringify (value [, Replacer] [, space])
Value: is a required field. is an object, an array, a class, and so on.
Replacer: is an optional field. It is divided into 2 different ways, one is an array, the second is a method.
Case one: When Replacer is an array, it is related to the first parameter, value. In general, serialization results are represented by key-value pairs. Therefore, if the value of the second parameter is present at the first, then the value of the second parameter is the key, the value of the first parameter is the expression of value, and if it does not exist, it is ignored.
Situation two: Replacer as a method, that is very simple, that is, the serialization of each object (remember that every one) into the method of processing.
Space: is an optional field. What makes a delimiter.
2,Json_decode ()
Json_decode ( string $json
[, bool $assoc
= False [, int $depth
= int $options
= 0]]]) 21>
< Span class= "type" > < Span class= "initializer" > json: json string
< Span class= "type" > < Span class= "initializer" >ASSOC: When this parameter is TRUE
, an array is returned
< Span class= "type" > < Span class= "initializer" >depth: User-specified recursion depth.
< Span class= "type" > < Span class= "initializer" >options:json bitmask option.
< Span class= "type" > < Span class= "initializer" > 3, example
< Span class= "type" > < Span class= "initializer" > front desk:
< Span class= "type" > < Span class= "initializer" > var arr=new Array (+/-);
var operatorids=json.stringify (arr);//Convert an array to a JSON string
$.ajax ({
Type: ' Post ',
Data: {' text ': text, ' Operatorids ': Operatorids},
URL: ' <?php echo $this->createurl (' letter/sendletters ');? > ',
Success:function (data) {
alert (data);
}
Background:
$model->operatorids= Json_decode (Yii::app ()->request->getparam ("Operatorids");
Ajax passing arrays