【问题标题】:How to get a value from PHP to ExtJs?如何从 PHP 获取值到 ExtJs?
【发布时间】:2015-09-18 09:50:16
【问题描述】:

如何从 PHP 函数获取值到我的 ext js 后端?

这样的Ajax请求能解决这个问题吗?

Ext.Ajax.request({
url: '{url action=getSqlDetails}',
params: {
count:count
},

在这种情况下,我需要 $count 变量。

public function getSqlDetailsAction() {
$fileName = $this->Request()->getParam('fileName');
$start = $this->Request()->getParam('start');
$limit = $this->Request()->getParam('limit');

$pluginFolder = dirname(dirname(__DIR__));
$sqlFolder = $pluginFolder . '/SqlFiles/';
$filePath = $sqlFolder . $fileName;
$sql = file_get_contents($filePath);
$count = substr_count($sql, '?');
if ($count > 0) {
    $this->View()->count = $count;
    //  Shopware()->Db()->query($sql, array(' EXT js fields from Filter Panel'));
} else {
    $sqlResultList = Shopware()->Db()->query($sql . " limit " . $start . ", " . $limit);
    $this->View()->success = true;
    $this->View()->data = $sqlResultList->fetchAll();
    $this->View()->total = Shopware()->Db()->query("select count(*) from ($sql) result")->fetchColumn();
}
}

【问题讨论】:

    标签: javascript php extjs get ajax-request


    【解决方案1】:

    访问Sencha Web Page了解更多信息

    Ext.Ajax.request({
        url: '{url action=getSqlDetails}',
        params: {
            count:count
        },
        // http success : code 200
        success: function(response){
            console.log(response.responseText);
        }
    });
    

    【讨论】:

    • 必须解析我的回报 :) ' var responseObj = JSON.parse(response.responseText),' 谢谢你的回答 :D
    猜你喜欢
    • 2011-12-14
    • 1970-01-01
    • 1970-01-01
    • 2017-02-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-14
    相关资源
    最近更新 更多