-1

我想知道是否可以做这样的事情:

 x$().xhr('<?php echo $this->createUrl('survey/index', array('id'=>$model->skey)); ?>', {
                method: 'POST',
                async: true,
                data: urlstringserialize(serialize(document.getElementById("token-form"))),
                callback: function() {respOK(this.responseText);}
            });
            x$().xhr('<?php echo $this->createUrl('survey/saveBrowser', array('id'=>$model->skey,'browser'=>$browser->getBrowser(),'platform'=>$browser->getPlatform())); ?>', {
                method: 'POST',
                async: true,
                data: urlstringserialize(serialize(document.getElementById("token-form"))),
                callback: function() {respOK(this.responseText);}
            });

我需要一个接一个地调用两个不同的控制器函数。这样,只执行第一个。

4

2 回答 2

0
 function respOK(data) {
        <?php if($browser->getBrowser() == Browser::BROWSER_IE) { ?>
        <?php if($campaignCenter->campaign_id == 326) { ?>
            x$("style").remove(".type");
        <?php } ?>
            x$('div.surveyform').html(data);
        <?php } else  { ?>
        <?php if($campaignCenter->campaign_id == 326) { ?>
            x$("style").remove(".type");
        <?php } ?>
            x$('div.surveyform').tween({opacity:0, duration: 200}, function() {x$('div.surveyform').html(data); x$('div.surveyform').tween({opacity: 1, duration: 200});});
        <?php } ?>
    }
于 2015-10-20T19:13:59.220 回答
0

如果你想在第一个请求之后执行第二个请求,你只需要在回调中发出请求。

 x$().xhr('<?php echo $this->createUrl('survey/index', array('id'=>$model->skey)); ?>', {
        method: 'POST',
        async: true,
        data: urlstringserialize(serialize(document.getElementById("token-form"))),
        callback: function() {
            respOK(this.responseText);
            x$().xhr('<?php echo $this->createUrl('survey/saveBrowser', array('id'=>$model->skey,'browser'=>$browser->getBrowser(),'platform'=>$browser->getPlatform())); ?>', {
                method: 'POST',
                async: true,
                data: urlstringserialize(serialize(document.getElementById("token-form"))),
                callback: function() {respOK(this.responseText);}
            });
});

唯一被调用的第一个问题可能取决于您使用的似乎是“x$”的库。

于 2015-10-20T19:10:32.363 回答