1

I've got the following problem, I send some value from jQuery to PHP via AJAX. My PHP script receives those value, and I would like that this script prints values in iframe in my www site. But instead, the script response contains all its source code to AJAX as response to the alert message. Does anybody know how can I stop returning code to AJAX and execute it by returning the values to be used in my iframe?

EDIT: further details: the problem is that my application has got two iframes from different servers, and I need to send values from one iframe to another. Because of cross domain restrictions, I cant do this via JS directly, so I figured out to send values via AJAX from one iframe to PHP on first server and PHP from first server to PHP on another server which is in iframe on my main page, and then show the data. so I must use AJAX to send it.

3
  • does the URL for your AJAX call end in .php ? Commented Feb 17, 2012 at 10:51
  • Yes, don't use AJAX. Post a form with the same action and data as your current AJAX post to the iframe instead. Commented Feb 17, 2012 at 10:54
  • I was thinking abut mafe a form to send but is it an 'elegant' way to do this? Commented Feb 17, 2012 at 10:56

1 Answer 1

1

You can't. PHP doesn't know about the iframe.

You are, presumably, using XHR to make the request, therefore XHR will receive the response.

If you want to load a document into an iframe, then load a document into the iframe (e.g. by setting its src to the URI for the document), don't play around with Ajax.

Sign up to request clarification or add additional context in comments.

2 Comments

ok, so how can I send values from jQuery/javascript to php script? that, when the script recive data it would refresh in iframe and write those data in iframe?
That is probably more trouble than it is worth (but see contents if you insist. You are still probably better off just setting the src of the iframe.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.