Based on my previous thread I’m trying to use ExtJS to call a function from a PHP class that lives in another area. Is this even possible or should I create a new PHP and simply pass it args? I’d prefer to use my existing code so I’m not duplicating it.
My current PHP Class handles my DB connection etc but I have no idea how or if I can instantiate the class and call a function using ExtJS.
<?php
class productInfo extends productInterface {
....
function getProducts($code) {
if (!$this->isConnected())
$this->connect();
$products = null;
$query = "SELECT id, product FROM products Where id = $code";
$result = $this->dbConnection->exec_query($query);
if ($result){
while($row = $this->dbConnection->fetch_array($result)) {
$products [$row['id']] = $row['product '];
}
}
return $products ;
}
}
?>
Client side code:
<select id="productFamily" onchange="getProducts()">
<option value="select">Select</option>
...
</select>
ExtJs
function getProducts(productFamily){
var value = Ext.get("productFamily").dom.options[Ext.get("productFamily").dom.selectedIndex].value;
Ext.Ajax.request({
// How do I call getProducts(value) from ExtJS ???
});
}
Is this possible?
drgomesp’s recommendation is definitely the easiest way to go.
However, there is a way to expose your server side API for use with ExtJS. If you really want to use your PHP functions via ExtJS, check out Ext Direct:
http://www.sencha.com/products/extjs/extdirect