By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,853 Members | 2,246 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,853 IT Pros & Developers. It's quick & easy.

Ajax result div display full self page in inner pages

P: 41
Hi

I have a newsletter form in the footer of every page. I want to submit that form without refreshing the page. So i am posting it using ajax.

I am using below code which works only on homepage till i dont visit the inner pages.

Dont know why its showing strange behaviour on inside pages.

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.     $(document).ready(function() {
  3.         $("#newsignup_bt").click(function() {
  4.                 $("#footer_result").show();
  5.                 $("#footer_result").fadeIn(400).html('<span class="load">Loading..</span>');
  6.                 $.ajax({
  7.                     type: "POST",
  8.                     url: "signup_footer.php",
  9.                     data: $("#newslet_footer").serialize(),
  10.                     cache: false,
  11.                     success: function(data) {
  12.                         $("#footer_result").html(data);
  13.                         document.getElementById('foot_name').value='';
  14.                         document.getElementById('foot_email').value='';
  15.                     }
  16.                 });
  17.  
  18.         return false;
  19.     });
  20.  
  21. });
  22. </script>
  23.  
Now what is happening is that this script is working perfectly on HOMEPAGE and sending and submitting data to database perfectly.

But when i go to inside pages and click the submit button, strange thing happens is

Like if i go to about us page or contact us page and these pages also have same form in the footer.

When i click the submit button on the about us page, Then the full about us page itself gets displayed in the RESULT DIV and form doesnt get submit.

When i click the submit button on the contact us page, Then the full contact us page itself gets displayed in the RESULT DIV and form doesnt get submit.

RESULT DIV (#footer_result) is the DIV which displays the "success" OR "error" message.

SUCESS Message : Your are subscibed to newsletter
Error Message : Error submitting form.

I Dont why is this happening. I have never experienced this kind of thing.

Hope you will be able to help me.

Thanks
Vineet
May 1 '15 #1
Share this Question
Share on Google+
1 Reply


Dormilich
Expert Mod 5K+
P: 8,639
this looks like an issue with the form processing script, not the script that loads the form.
May 5 '15 #2

Post your reply

Sign in to post your reply or Sign up for a free account.