Extjs Php/mysql Backend Connector Error
exactly the same problem than on this post follow carefully the documentation (official) https://docs.sencha.com/extjs/6.5.3/guides/backend_connectors/direct/mysql_php.html did no
Solution 1:
I guess you are also following the guide and using the sencha app watch and getting the php code returning back to you. I found this answer on a Sencha forum that the web server that the sencha cmd provides doesn't support php is just a basic HTTP web server.
Solution 2:
I was looking at the exact same thing today and came across the post....
For anyone else looking for the problem this is how i fixed it. Basically you have to get the posted data in a slightly different manner... looks at the first comment in the code below
<?phprequire('config.php');
classBogusAction{
public$action;
public$method;
public$data;
public$tid;
}
$isForm = false;
$isUpload = false;
// different way to get the data that is posted to the URL $postData = file_get_contents('php://input');
if (isset($postData)) {
header('Content-Type: text/javascript');
$data = json_decode($postData);
}
elseif (isset($HTTP_RAW_POST_DATA)) {
header('Content-Type: text/javascript');
$data = json_decode($HTTP_RAW_POST_DATA);
}
elseif(isset($_POST['extAction'])){ // form post$isForm = true;
$isUpload = $_POST['extUpload'] == 'true';
$data = new BogusAction();
$data->action = $_POST['extAction'];
$data->method = $_POST['extMethod'];
$data->tid = isset($_POST['extTID']) ? $_POST['extTID'] : null;
$data->data = array($_POST, $_FILES);
}
else {
die('Invalid request min .');
}
functiondoRpc($cdata){
$API = get_extdirect_api('router');
try {
if (!isset($API[$cdata->action])) {
thrownewException('Call to undefined action: ' . $cdata->action);
}
$action = $cdata->action;
$a = $API[$action];
$method = $cdata->method;
$mdef = $a['methods'][$method];
if (!$mdef){
thrownewException("Call to undefined method: $method " .
"in action $action");
}
$r = array(
'type'=>'rpc',
'tid'=>$cdata->tid,
'action'=>$action,
'method'=>$method
);
require_once("classes/$action.php");
$o = new$action();
if (isset($mdef['len'])) {
$params = isset($cdata->data) && is_array($cdata->data) ? $cdata->data : array();
}
else {
$params = array($cdata->data);
}
$r['result'] = call_user_func_array(array($o, $method), $params);
}
catch(Exception$e){
$r['type'] = 'exception';
$r['message'] = $e->getMessage();
$r['where'] = $e->getTraceAsString();
}
return$r;
}
$response = null;
if (is_array($data)) {
$response = array();
foreach($dataas$d){
$response[] = doRpc($d);
}
}
else{
$response = doRpc($data);
}
if ($isForm && $isUpload){
echo'<html><body><textarea>';
echo json_encode($response);
echo'</textarea></body></html>';
}
else{
echo json_encode($response);
}
?>
Post a Comment for "Extjs Php/mysql Backend Connector Error"