Note that there are some explanatory texts on larger screens.

plurals
  1. POReplace a div with another div in ajax/javascript?
    primarykey
    data
    text
    <pre><code>&lt;div class="col" style="border-right:none; color: #FFFFFF;"&gt; &lt;form id="form-search" method="post" action="&lt;?php echo $_SERVER['PHP_SELF'];?&gt;"&gt; &lt;span&gt; &lt;span class="style2"&gt;Enter you email here&lt;/span&gt;: &lt;/span&gt; &lt;input name="email" type="email" id="email" required/&gt; &lt;input type="submit" value="subscribe" class="submit" style="height:30px;"/&gt; &lt;?php if($_POST['email']!="") { mysql_connect("localhost","",""); mysql_select_db(""); error_reporting(E_ALL &amp;&amp; ~E_NOTICE); $email=$_POST['email']; $sql="INSERT INTO newsletter_email(email) VALUES ('$email')"; $result=mysql_query($sql); if($result){ echo "You have been successfully subscribed."; } if(!$sql) die(mysql_error()); mysql_close(); } ?&gt; &lt;/form&gt; &lt;/div&gt; </code></pre> <p>After the user got subscribed, I want to replace my subscription form and display the echo statement.</p> <p>This code is running totally fine and is very good too; just want some more advantage with it.. ..</p> <p>it shows like this<img src="https://i.stack.imgur.com/9RQ8k.png" alt="enter image description here"></p> <p>But i want to show it like this <img src="https://i.stack.imgur.com/NixtL.png" alt="enter image description here"></p> <blockquote> <p>my code now</p> </blockquote> <pre><code>&lt;div class="col" style="border-right:none; color: #FFFFFF;"&gt; &lt;script&gt; var form = $('#form1'); $.ajax{ type:form.attr('method'), url:form.attr('action'), data:$("#form1").serialize(), success: function(data){ if(data=="You have been successfully subscribed."){ $(".col").html("&lt;div&gt;Welcome&lt;/div&gt;") } } &lt;/script&gt; &lt;form id="form1" method="post" action="index.php"&gt; &lt;span&gt;&lt;span class="style2"&gt;Enter you email here&lt;/span&gt;:&lt;/span&gt; &lt;input name="email" type="email" id="email" required/&gt; &lt;input type="submit" value="subscribe" class="submit" style="height:30px;"/&gt; &lt;?php if($_POST['email']!="") { mysql_connect("localhost","",""); mysql_select_db(""); error_reporting(E_ALL &amp;&amp; ~E_NOTICE); $email=$_POST['email']; $sql="INSERT INTO newsletter_email(email) VALUES ('$email')"; $result=mysql_query($sql); if($result){ echo "You have been successfully subscribed."; } if(!$sql) die(mysql_error()); mysql_close(); } ?&gt; &lt;/form&gt; &lt;/div&gt; </code></pre>
    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