Send request parameters to another controller/action in zend 1 - ajax

i am working in zend project and need to post request to certain page via ajax. Then i need to carry the request data and post it to another controller and action of same project which should return me some data as well.

Related

Session not available for first request to an external webpage

From my JSF page, I am redirecting to an external URL (another server) through a POST request using this: JSF commandButton - passing POST params to an external site.
The external URL is a JSF webpage of another JSF webapp being called for the first time. At the receiving end inside request filter doFilter() method I see that session is invalid for the incoming request. Is it because request is coming from a different server and request is bound to an old session id which is not in the scope of current server? I do need a valid session at this point. Do I need to recreate session? Or why JSF is not creating session automatically on the first request at this web page on second server? Is it because the first request is a POST instead of GET on the second server web page?
I would also like to tell that this problem is happening for only the first request on the second server.

laravel validation during ajax request

Please somebody explain this info from Laravel docs "When using the validate method during an AJAX request, Laravel will not generate a redirect response. Instead, Laravel generates a JSON response containing all of the validation errors. This JSON response will be sent with a 422 HTTP status code."
What does "during an AJAX request" exactly mean here?
If I'm set like this:
User submits input from a form in the view.
The route calls the method for post in the controller
The request is validated in the controller
case 1) Request passes validation and input is stored in the DB -> Response is returned as JSON for a script that updates the view on the fly.
case 2) Request doesn't pass validation, what is returned here? I think a redirect and if not how can you check if validation has failed to return a JSON instead?
And is this scenario similar to what the docs talk about? If not then what?
The response to an AJAX call in this case is a JSON string
Case 1: as you said
Case 2: A JSON String with the error messages. Look into your Chrome dev tools into the Network tab, there you'll see the exact responses.
When handling a validation failure, laravel automatically generates an error response. Normally this will redirect the user back to their form, but in the case of an AJAX request it will instead return a JSON response with the details of what failed validation.
Laravel relies on the symfony request object to detect AJAX requests, specifically this line:
return 'XMLHttpRequest' == $this->headers->get('X-Requested-With');
If you are encountering issues with your requests not being treated as AJAX, make sure your client is properly setting the X-Requested-With header

How do I handle an MVC Cross site POST?

I have to handle Cross site POSTS from Ajax calls in an MVC project.
I have a method in my controller that is supposed to accept a POST with the view model as the POST body. My page is making an ajax call to it from Javascript. This works fine if everything is under the same domain.
IE11 sends an OPTIONS request without a POST body the first time my Ajax call is made. MVC tries to route this, fails to find my method (probably because it takes the ViewModel parameter), and returns a 404. However after the first time the call errors out, subsequent calls include the POST body and are routed successfully.
I thought I could fix this easily by including an overload of my method in my controller that takes no parameters and returns a 200 (or 204) and no message body. However this gives me "The current request for action on controller type is ambiguous between the following action methods" and lists both overloads.
What is the best way to get this to route correctly? If I got to my controller method with a null ViewModel, I could return a 200/204 and probably be okay - but I don't get there, routing sends back a 404.
Solved this. CORS requires 2 things, you need all responses to include the Access-Control-Allow-Origin header, and you need to response to OPTIONS requests (either with a 200 or 204).
My OPTIONS requests were not routing correctly, returning a 404 with the Access-Control-Allow-Origin header, which caused the error but allowed the next request to work without an OPTIONS request.
I had to handle the OPTIONS requests in my Global.asax.cs

How do you return a response to an Ajax request server side from struts 1.3?

I would like to integrate some Ajax techniques into an existing struts application.
How do I send the requested data back server side to the client without causing the page to reload?
If you called the server side with Ajax, the page will not reload. You don't have to do anything special on the server side. Although, obviously, you should do your Ajax request to a different page made for that purpose, not to the same page.

How To post Form data to Cross Domain Without Page Refresh

I have tried lot regarding Post form data to Cross domain using Ajax post method. but i received success response. but the Form data is not posted to the requested cross domain instead of shows 404 network error in browser.
can anyone suggest How to Post the Form Data to Cross domain in ASP.NET MVC application?

Resources