Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've been unable to find a way to detect an <code>iframe</code>'s server response, but it looks like the purpose of your <code>iframe</code> is just to show the results of the form submission request without a page refresh. If so, then maybe you can replace the <code>iframe</code> with an <a href="http://en.wikipedia.org/wiki/XHR" rel="nofollow">XHR</a> call.</p> <p>I'd recommend using some flavor of <a href="http://ajaxcontroltoolkit.codeplex.com/" rel="nofollow">Ajax library</a> for simplicity, but I've had a few scenarios where that wasn't an option for one reason or another. Here's a toy example of how to make an XHR form submission request using Javascript without AJAX.</p> <p><strong>NOTE:</strong> This example assumes the <code>form</code> is not sending file data (that's a whole other kettle of fish, and much better handled with AJAX). It also won't submit the values of <code>&lt;select&gt;</code> or <code>&lt;textarea&gt;</code> tags, but you could certainly extend the javascript to handle those.</p> <pre><code>/* HTML */ &lt;form action="script.php" method="post" // these are up to you onsubmit="sendFormRequest(this); return false;"&gt; /* Javascript */ function sendFormRequest(form){ var fields = form.getElementsByTagName('input'); var data = []; for(var i=0; i&lt;fields.length; ++i){ if(fields[i].getAttribute('type') != 'submit') data[i] = escape(fields[i].name) + '=' + escape(fields[i].value); } var req = new XMLHttpRequest(); req.open(form.getAttribute('method'), form.getAttribute('action'), false); req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); req.send(data.join('&amp;')); return {'status':req.status, 'responseBody':req.responseText}; } /* Returns */ Object { status=200, responseBody="&lt;!DOCTYPE html PUB ... \n&lt;/body&gt;\n&lt;/html&gt;\n" } </code></pre> <p>I doubt this post is still relevant, I'm mainly replying to it because it comes up in search results and doesn't seem to have a quick, usable answer.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload