This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

Ajax helpers beyond a domain?

Forum to discuss ExtJS and other JS plugins

Ajax helpers beyond a domain?

by liri » Sun Dec 14, 2008 1:38 am

Hey everyone,

For the lack of an Ajax specific section in the forum I reverted to the Javascript plugins topic so I hope this is the right place indeed...

So anyway, I'm reading http://www.symfony-project.org/book/1_2/11-Ajax-Integration to get a clue about Ajax in Symfony and there's a note saying that "The Ajax helpers won't work if the URL of the remote action doesn't belong to the same domain as the current page".

What is considered a "domain" is it the module? the app?
I'm asking because I would figure that Ajax callback pages should reside in the 'backend' side of a project, shouldn't they?

Thanks.
liri
Junior Member
 
Posts: 29
Joined: Thu Nov 27, 2008 7:17 pm

Re: Ajax helpers beyond a domain?

by halfer » Thu Dec 18, 2008 12:30 pm

This is not a symfony restriction - this is a browser restriction, implemented for good security reasons.

I'd say an AJAX thing ought to be in the same application as the page that employs it. So if you are in a frontend app, any AJAX stuff should also be in the frontend.
halfer
Faithful Member
 
Posts: 10148
Joined: Mon Jan 30, 2006 1:16 pm
Location: West Midlands, UK

Re: Ajax helpers beyond a domain?

by liri » Thu Dec 18, 2008 12:49 pm

Good point you raised and here's a similar situation then...
There's a page showing info about an item and in the bottom of it there's the listing of comments about this item. Meaning, there's an item module and a comments module, both in the frontend app.

On the page that shows the item I would like to allow to submit a comment using AJAX. So to which target action should I redirect the form submission? to the comments module on the frontend? Should I submit it to the same action of the regular form submit or to a specific AJAX action to push in the data to the database?

Thanks.
liri
Junior Member
 
Posts: 29
Joined: Thu Nov 27, 2008 7:17 pm

Re: Ajax helpers beyond a domain?

by halfer » Thu Dec 18, 2008 3:59 pm

You can choose to either use the same form submit action (but detect that it's an AJAX POST and respond accordingly) or a different one. It might be quite elegant to use one for both, but either is fine. If this is for a comments section then yes, put it in your comments module.
halfer
Faithful Member
 
Posts: 10148
Joined: Mon Jan 30, 2006 1:16 pm
Location: West Midlands, UK