Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing the jquery get function to load a page with a contact form
    primarykey
    data
    text
    <p>I put together a simplified example of my problem. My HTML code is as follows:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script style="text/javascript"&gt; $(document).ready(function(){ $('a.mylink').click(function(e){ //get the querystring var href=$(this).attr('href'); var querystring=href.slice(href.indexOf('?')+1); $.get('test_jq.php', querystring, function(data) { //load the data $('#mydiv').html(data); }); //stop the link return false; }); $('#contact').submit(function() { alert("you have submitted"); return false; }); // end submit }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;a class="mylink" href="test.php?info=A" &gt;A&lt;/a&gt; &lt;a class="mylink" href="test.php?info=B" &gt;B&lt;/a&gt; &lt;a class="mylink" href="test.php?info=C" &gt;C&lt;/a&gt; &lt;div id="mydiv"&gt; Information loaded here. &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Here is the test.jq php file:</p> <pre><code>&lt;?php if ($_SERVER['REQUEST_METHOD'] === 'GET' and isset($_GET["info"]) ) { $info=$_GET["info"]; if($info=="A")echo "A"; elseif($info=="B") { echo '&lt;form id="contact" method="post" action="email.php" &gt; &lt;label&gt;Name&lt;/label&gt; &lt;input type="text"&gt; &lt;button type="submit"&gt;Submit&lt;/button&gt; &lt;/form&gt;'; } elseif($info=="C") echo "C"; } Here is a working example: http://www.scratchprogramming.org/test.php </code></pre> <p>Essentially, I am having trouble accessing the handler:</p> <pre><code>$('#contact').submit(function() { alert("you have submitted"); return false; }); // end submit </code></pre> <p>when I click the B link and then submit the form ?</p> <p>Here is a working example:</p> <p><a href="http://www.scratchprogramming.org/test.php" rel="nofollow">Working example</a></p> <p>Thanks..Jillian</p>
    singulars
    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.
 

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