View Full Version : [SOLVED] Can not call API action in JavaScript

29 May 2009, 6:25 AM

i'm exploring Ext.Direct and stumble when calling the API actions in JavaScript. I'm using this PHP stack http://extjs.com/forum/showthread.php?t=68186.

On server side i have coma_api.php which runs this code after all the default stuff:

$api = new ExtDirect_API();

$api->setRouterUrl('coma_router.php'); // default

Within my test index.php i have this at the end of the file:

<script type="text/javascript" src="coma_api.php"></script>
<script type="text/javascript">
window.onload = function(){

COMA_API_ViewHandler.getUI(function(provider, response){
alert('tell todd');

When i open index.php Firebug tells me:

Ext.app.REMOTING_API = {"url":"coma_router.php","type":"remoting","actions":{"COMA_API_ViewHandler":[{"name":"getUI","len":0,"serverMethod":"getUI"}]},"namespace":"Ext.app"};
But calling COMA_API_ViewHandler gives me an JS error:

Fehler: COMA_API_ViewHandler is not defined
Quelldatei: https://myserver/index.php
Zeile: 46What i'm doing wrong? Do i miss anything?

Thanks in advance and best regards,
Jean Marie

29 May 2009, 12:07 PM
Off the top of my head, have you tried Ext.app.COMA_API_ViewHandler.getUI?

1 Jun 2009, 11:42 PM
Thanks, using the defined namespace makes sense and works!

When i
console.log(Ext.app);Firebug tells me:

I ran into this error because i followed the official Ext.Direct description (http://extjs.com/products/extjs/direct.php (http://extjs.com/forum/../products/extjs/direct.php)). See chapter Client Side portions of Ext.Direct:

AlbumList.getAll(function(provider, response) {
// process response

Thanks and best regards,
Jean Marie

8 Jun 2009, 1:35 PM
Jean Marie -

If you specified no namespace your client-side stubs would have been generated in the window namespace. Because you specified "Ext.app", they are available there.

11 Jun 2009, 4:28 AM
Because you specified "Ext.app", they are available there.

100% ;-). I got it.

I tried it without specifying the namespace on server side within the PHP stack implementation and than it works like the documentation example.

But i would prefer the namespace variant.

Thanks and best regards,
Jean Marie