Can't add cookies to ajax page JSP - ajax

I'm developing a simple JSP page with a div updated via AJAX XMLHttpRequest object
When I try to use (response.addCookies(String,String)) I get no errors but the page stops loading and there are no output whatsoever...
Are there no way I can add cookies through an Ajax request object???

Related

How to reload a JSP page after all ajax calls get completed using javascript (without using jquery)

We fire n number of ajax calls from a jsp page, and we need to reload the page after all the ajax calls get completed. Can someone please advise as how I could do this using javascript(without using jquery).
Thanks.

CakePHP redirect entire page instead of div

When I'm logging in with my CakePHP login function in the Users controller using ajax. The errors will be displayed in an Div above the login form. But when I have a successful login, I want to redirect the page to the homepage. When I'm using $this->redirect('home'); in the Users controller, the Div will only be updated.
How can I make sure that the entire page will be reloaded? I rather fix this problem with PHP than Javascript 'cause I'm using the Writebuffer method with the JSHelper.
Thanks!
This should be solved in client side. Because client browser gets the AJAX response and puts the output inside the DIV.
Although you can embed javascript code inside the AJAX response. For example, if login is incorrect, then put a window.location javascript code inside the output. But this is not a good solution.
Return an HTTP status code within AJAX response. If for example code is 401, then redirect.
if (data == '401') {
document.location.href="http://example.com";
}

flashmessenger can`t show anything when page loading with ajax

i have a form that it send data with ajax post metod. when i set flashmessenger in action method, it don`t show any messege (i have to refresh the page for see the messege)!
how i can manage the flashmessenger for recognition ajax load page??
Flashmessenger uses sessions, in order for it to work you need to physically reload the page. You have to create your own mechanism; Whenever you get the callback you can append lets say your response to the same element in which you would have displayed the flashmessanger message.

Ajax load a page like an include

I have a problem: I need to load a set of includes with ajax, but when I make the ajax
and request the current URL, I get the page url.
I have a problem when I call a page via ajax; the problem is when I try to get the request
URL in the page which is called with ajax, because it doesn't work like an include.
For example: I have my page "prueba.adp" and "prueba-ajax.adp"
The page prueba.adp calls via ajax to prueba-ajax.adp.
So when I try to get the request URL in prueba-ajax.adp I get prueba-ajax.adp, but
if I set an include I get prueba.adp.
Do you know any way to execute the ajax page and get the request url of the page which made the ajax call?

Ajax request returns a 404 but URL works fine

I'm doing an jQuery ajax call to an XML page in my CakePHP site. For some strange reason CakePHP returns a 404 error when I do an ajax call, yet there is no problem going to the URL directly at http://imgfave.com/gragland/rss.
You can see the issue by clicking the link on my test page: http://imgfave.com/ajaxtest
The error page says: "The requested address '/gragland/rss' was not found on this server".
Why would CakePHP have a problem returning the page only when fetched via ajax?
According to FireBug, the main difference between the requests is:
X-Requested-With XMLHttpRequest
From AJAX request.
P.S.: After a quick test using the same headers, it retrieves the RSS without error
Make sure you have a view file. An html request will return without error without a view. But AJAX request returns 404.

Resources