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!\)))); }
调用的地方在usertest/index.php里面,代码如下:
array( 'name' => 'usertest_comments', 'id' => 'usertest_comments', 'header'=>'comments', 'type'=>'raw', 'value'=>'$data->gettextarea(\'usertest_comments\',$data->usertest_id)', 'htmloptions'=>array('style'=>'width:100px;'), ),
开发在windows上,页面访问没有问题,访问路径是正确的: */usertest/changecomments, 可是放到linux上却变成:*/usertest/usertest/changecomments,导致修改不了数据。2. 尝试了一下方法,,
①以为是单双引号的问题,代码改成下面这样:
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!\)))); }
问题还是没有解决,又改成单引号,直接报错了。后面改回来时windows上竟然也报错了,跟linux一样,无语了。
②把url=>usertest/changecomments改成url=>/usertest/changecomments, linux对大小写敏感,发现还是不行。
③后面改成这样子的:url=>http://enduserfeedback.ta-mp.com:8080/usertest/changecomments,windows上没有问题了。结果放到linux上,发现报错了,
no 'access-control-allow-origin' header is present on the requested resource. origin 'http://172.24
百度了下,按照这个文章(点击打开链接)改了之后,可以了。后面把绝对路径去掉,只留下datatype=>jsonp, 貌似也没有问题。
3. 反正程序总是来回折腾,最后就这样解决了问题
以上就介绍了linux php下ajax请求时url路径出现重复,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。
