Alex
Alex

Reputation: 467

How to get a value from PHP to ExtJs?

How can I get a value from a PHP function to my ext js backend?

Is it possible to solve this problem with an Ajax request like this?

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

In this case I need the $count variable.

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();
}
}

Upvotes: 1

Views: 1370

Answers (1)

Halayem Anis
Halayem Anis

Reputation: 7785

Visit Sencha Web Page for more informations

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

Upvotes: 3

Related Questions