Home >Backend Development >PHP Tutorial >URL paths are repeated during Ajax requests under linux php
1. The YII framework used in the project has a method in Usertest.php under the module:
public function getTextArea($fieldName,$usertest_id) { return CHtml::activeTextArea($this,$fieldName,array("name"=>$fieldName."_".$usertest_id,'style'=>'rows:3;cols:20;',"ajax" => array("type"=>"POST","url"=>"/usertest/ChangeComments", "data"=>array("usertest_id"=>$usertest_id,"usertest_comments"=>"js:this.value"),"success"=>"js:alert(\"Update comments success!\")"))); }is called in usertest/index.php, the code is as follows:
array( 'name' => 'usertest_comments', 'id' => 'usertest_comments', 'header'=>'Comments', 'type'=>'raw', 'value'=>'$data->getTextArea(\'usertest_comments\',$data->usertest_id)', 'htmlOptions'=>array('style'=>'width:100px;'), ),
public function getTextArea($fieldName,$usertest_id) {
return CHtml::activeTextArea($this,$fieldName,array("name"=>$fieldName."_".$usertest_id,"style"=>"rows:3;cols:20;","ajax" => array("type"=>"POST","url"=>"usertest/ChangeComments","data"=>array("usertest_id"=>$usertest_id,"usertest_comments"=>"js:this.value"),"success"=>"js:alert(\"Update comments success!\")")));
}
The problem was still not solved, so I changed it to single quotation marks again. Quotation marks, an error is reported directly. When I changed it back later, an error was also reported on Windows. It was the same as Linux. I was speechless.
Baidu, after changing it according to this article (click to open the link), it's OK . Later, I removed the absolute path and left only "dataType" => "JSONP", which seemed to be no problem.
3. Anyway, the program always went back and forth, and finally the problem was solved like this
The above introduces the duplication of URL paths during Ajax requests under Linux PHP, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.