Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to post HTML code using Ajax?
    primarykey
    data
    text
    <p>I'm making HTML, PHP and Ajax based site for my university class and having some problems that I can't figure out. Can I post my HTML based Registration Form using Ajax post method to my main PHP site? My code looks like this:</p> <p>index.php</p> <pre><code>&lt;form id="loginForm" action="login.php" method="POST"&gt; Username: &lt;input type="text" name="username" id="username"/&gt;&lt;br/&gt; Password: &lt;input type="password" name="password" id="password"/&gt;&lt;br/&gt; &lt;button id="submit"&gt;Login&lt;/button&gt; &lt;button id="regButton"&gt;Register&lt;/button&gt; &lt;/form&gt; &lt;div id="ack"&gt;&lt;/div&gt; &lt;div id="regAjax"&gt;&lt;/div&gt; &lt;script type="text/javascript" src="Script/jquery-2.0.3.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="Script/scriptAjax.js"&gt;&lt;/script&gt; </code></pre> <p>register.html</p> <pre><code>&lt;html&gt; &lt;head&gt;&lt;title&gt;Registration Form&lt;/title&gt;&lt;/head&gt; &lt;body&gt; &lt;form id="regForm" action="process.php" method="POST"&gt; Username: &lt;input type="text" name="username"/&gt;&lt;br/&gt; Password: &lt;input type="password" name="password"/&gt;&lt;br/&gt; First Name: &lt;input type="text" name="fname"/&gt;&lt;br/&gt; Last Name: &lt;input type="text" name="lname"/&gt;&lt;br/&gt; E-mail: &lt;input type="text" name="email"/&gt;&lt;br/&gt; &lt;button id="register"&gt;Register&lt;/button&gt; &lt;/form&gt; &lt;div id="rck"&gt;&lt;/div&gt; &lt;script type="text/javascript" src="Script/jquery-2.0.3.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="Script/scriptAjax.js"&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>scriptAjax.js</p> <pre><code>$("#regButton").click( function() { $.post ??? $("#regButton").submit( function() { return false; }); }); </code></pre> <p>So the main purpose of this to make the smoother page and that registration form would appear in <code>&lt;div id="regAjax"&gt;&lt;/div&gt;</code> place when Register button is clicked, that user could register not being redirected to another page. Is there a way to do that or I'm taking the wrong path now?</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.
 

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