简体   繁体   中英

ajaxSubmitButton not working on linux server

Below is an ajaxSubmitButton that in working on a mac but not on a linux server. On the linux server Error Console shows this error: SyntaxError: missing } after property list

<?php
     echo CHtml::ajaxSubmitButton(
        '',          
        array('/modelA/action'), 
        array(
            'type'=>'POST',
            'success' => 'js:function(){window.location="/modelB/action"}',
        ),
        array(
            'id'=>'button',
        )
    ); 
?>

When I copy the error from Firebug or Error Console I get this:

SyntaxError: missing } after property list https://www.mysite.com/assets/95062282/jquery.ba-bbq.js Line 853

and Firebug looks like this:

在此处输入图片说明

You need to remove the 'js:' part in your code (before function) then it should work

So it will look like this:

<?php
     echo CHtml::ajaxSubmitButton(
        '',          
        array('/modelA/action'), 
        array(
            'type'=>'POST',
            'success' => 'function(){window.location="/modelB/action"}',
        ),
        array(
            'id'=>'button',
        )
    ); 
?>
array(
        'id'=>'button',
                      ^---

dangling commas are the source of many JS problems.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM