Need Help with cross domain AJAX and PHP Proxy
Moderator: General Moderators
Need Help with cross domain AJAX and PHP Proxy
Hi, Im hoping one of you experts can help point me in the right direction. I have a forum that submits to a WCF service, and the WCF returns a table with a successFlag in it. I don't want my users to leave my page when they submit the form (jquery .ajax makes that easy on my server) but since Im going cross domain its difficult. I am trying to set up a Proxy via PHP on my server to send the data to the WCF, and hopefully return the successFlag from the WCF to my page, making my page think its coming from my domain so I can populate the appropriate message on the page. Am I going down the right path with the PHP proxy? Im guessing I would use curl, any help is greatly appreciated and will be dually noted!
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Need Help with cross domain AJAX and PHP Proxy
That is pretty much the standard approach.
Re: Need Help with cross domain AJAX and PHP Proxy
I understand the basics of setting up the Proxy (lots of documentation on the web), so my form submits through the proxy script, which Posts it to the WCF server. The end server gets the Post and and sends its response. Where Im struggling to understand the workflow, is there another script that handles the response? Would that script have the if statements that echo success/failure and then my .ajax jquery submit would function off of that? How do I go about learning about this, what is the proper terminology I should be looking at. Im not that familiar with PHP functions, so any help is greatly appreciated. After all, Im just an old Marine!
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Need Help with cross domain AJAX and PHP Proxy
I'm not exactly sure what you are talking about. There isn't generally an intermittent step between your proxy script and your ajax callback. However, my preference would be to put all the logic on your server side proxy script, and return a simple json/xml/whatever response (success/failure or whatever other information the client side needs) to handle updating the user interface.DirtyBird wrote:I understand the basics of setting up the Proxy (lots of documentation on the web), so my form submits through the proxy script, which Posts it to the WCF server. The end server gets the Post and and sends its response. Where Im struggling to understand the workflow, is there another script that handles the response? Would that script have the if statements that echo success/failure and then my .ajax jquery submit would function off of that? How do I go about learning about this, what is the proper terminology I should be looking at. Im not that familiar with PHP functions, so any help is greatly appreciated. After all, Im just an old Marine!
Re: Need Help with cross domain AJAX and PHP Proxy
Apologies for being confusing, its a reflection of my level of understanding. Honestly, I dont know how to trigger the success function in the .ajax callback other than checking if the fields were filled correctly and echoing success/failure-basic server side validation. So one script that sends the POST to the WCF, and receives its response. Then there is something in that PHP script that triggers the success function? The response is a table with one of the tr's containing a td that is "successFlag" the td next to it is a boolean. I need to show my success msg if it is true, my error msg when its false. I greatly appreciate your time.