Quantcast
Channel: User JohnP - Stack Overflow
Viewing all articles
Browse latest Browse all 37

Answer by JohnP for Linking page in a div with html forms and php

$
0
0

Since you've tagged jQuery, I'll use a jQuery example

$(document).ready(function(){    $('form').submit(function(){       $('#content').load('code.php');       return false;    })})

This makes a couple of assumptions here

  1. This assumes that code.php is in the same path that you are in now.
  2. There is only one form in the page.
  3. As @johnhunter points out, this example obviously won't work with post. You can send the post data along with the method. See here for usage : http://api.jquery.com/load

EDIT

Here's a fiddle example : http://jsfiddle.net/jomanlk/J4Txg/

It replaces the form area with the content from jsfiddle/net/echo/html (which is an empty string).

NOTE 2 Make sure to include the code in $(document).ready() or include it at the bottom of the page. It goes without saying you need jQuery in your page to run this.


Viewing all articles
Browse latest Browse all 37

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>