View Full Version : store.sync using proxy.ajax and api property

23 May 2013, 1:28 PM
I'm using EXT-JS 4.2.1

I have a json store with an ajax proxy and a json reader and writer.
I'm tring to implement CRUD with back end php server.

The store.load() function works perfectly fine.

But the store.sync() function will not use the url(s) setup in the api property
It always defaults to index.php for the sync, striping off the action parameter.

read: "index.php?action=Load",
create: "index.php?action=Create",
destroy: "index.php?action=Destroy",
update: "index.php?action=Update"

This is a problem for me because I can't tell the back end server what operation to perform on the database since the sync operations are batched, I can't manually set the action parameter for each operation.

Is this a known issue, if so when will it be fixed?

Does anyone know a work around that don't involve using direct?

28 May 2013, 10:13 AM
I've not heard of that issue. Can you post your entire store config?

28 May 2013, 11:23 AM
My Bad.
What I described before was a misinterpretation of what was really going on due to the difference in get and post requests when using the load and sync commands.

Here is the real problem:
during store.sync() up to three separate requests are batched together and sent to the server.
My php server relies on the request parameter "action" to determine what action the server needs to perform.
Is there a way to set an action parameter to each request method of the sync command.

I have tried setting the api to { load : 'index.php?action=load', create: 'index.php?action=insert', destroy: 'index.php?action=delete', update: 'index.php?action=update'}
The load method does a get request so the server receives the api action parameter.
But the sync method uses post requests, and because of that, the attached action parameter in the api is not read by the php server

I got around this issue by setting the api action parameter by url using the .htaccess file and the rewrite command. But there must be an easier way.

28 May 2013, 2:34 PM
If you set the API params to something like:
create: 'app.php?create=true'

That should send up something like:

with params like:


as a POST (when doing create). Is is messing with your server to see those coming through as POSTs? If so, you can either check out how to grab params posted to PHP or you can change the actionMethods used by the proxy.

28 May 2013, 3:07 PM
Hi slemmon,

That's about what I had to do to get past the problem.

Just a suggestion for future releases:
Might be nice to add extraParams like property to the api in some fashion
to avoid getting a mix of get and post parameters in request object.