View Full Version : Will Ext.Direct call across servers?

2 Nov 2009, 11:15 AM
Does Ext.Direct work across servers? I have my API on one host and I'm trying to use from JavaScript hosted elsewhere. Are Ext.Direct calls subject to the same host restriction?

My remote remote API has the fully resolved URL :

Ext.app.REMOTING_API = {"url":"http://localhost:8080/remote/"

I can call remote methods just fine when I load the javascript code from the URL, but does not work however when I run it from the a directory and try to call to the server. This is simulating a cross-host call. Firebug shows me that the GET to load the remote API works fine, however the POST to execute the command does not make it to the server. The POST in Firebug looks strange; instead of labeling it "POST remote," it is labeled "OPTIONS remote."

2 Nov 2009, 12:03 PM
It's not "direct" that you need to focus your question on, it's the proxy that it uses. To call a different host, you will need script tag proxy

2 Nov 2009, 12:27 PM
Great, after reading about the ScriptTagProxy (http://www.extjs.com/deploy/ext/docs/output/Ext.data.ScriptTagProxy.html), it looks like I can check for a callback request parameter on the server and wrap the JSON returned in the method call (JSONP). This would work great for a Store, but I'm using the addProvider.

So, what do I have to do to get this to work? Note, the router is not of the same origin(host) as this code:


The desired result is the ability to call the method simply by stating:


The technique is more flexible then plugging into the Store directly and can still be used with the Store by passing these methods to the Store's API parameter.

5 Nov 2009, 8:48 AM
Is this a new or current feature?

5 Nov 2009, 9:02 AM
Is this a new or current feature?


5 Nov 2009, 9:12 AM
Sorry, I'm still lost on how to do this.... I guess I'm asking for a short example with ScriptTagProxy and addProvider. I have been looking and reading for the better part of a day...

So, the remote API defines a call called Action.multy. I would like to make the remote call simply by writing "Action.multy(2)" in Javascript. This is the functionality already provided by addProvider. Only, by default, this is subject to the same origin policy. I see examples of using the ScriptTagProxy with the data store. There are none using Direct.addProvider though. So, i'm wondering if this fits or if I need to look at implementing something like it.