473,385 Members | 1,553 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Ajax Script problem...

I have the following Ajax script to process a form within my DIV:

Expand|Select|Wrap|Line Numbers
  1.   <script type="text/javascript">                                         
  2.    // we will add our javascript code here           
  3.  
  4. $(document).ready(function(){
  5. $("#ajax-contact-form").submit(function(){
  6.  
  7. var str = $(this).serialize();
  8.  
  9.    $.ajax({
  10.    type: "POST",
  11.    url: "contact.php",
  12.    data: str,
  13.    success: function(msg){
  14.  
  15. $("#note").ajaxComplete(function(event, request, settings){
  16.  
  17. if(msg == 'OK') // Message Sent? Show the 'Thank You' message and hide the form
  18. {
  19. result = '<div class="notification_ok"><br><br><br><br><br><blockquote>Thank You!<p>Your message has been sent and we will contact you at our earliest conveniece.<p>Thank you!</blockquote></div>';
  20. $("#fields").hide();
  21. }
  22. else
  23. {
  24. result = msg;
  25. }
  26.  
  27. $(this).html(result);
  28.  
  29. });
  30.  
  31. }
  32.  
  33.  });
  34.  
  35. return false;
  36.  
  37. });
  38.  
  39. });
  40.  
  41.  </script> 

I have manipulated this script for another DIV, but it's not producing the same results as the first div - even after renaming the DIV ID.

I have a semi-working version of it here for you to see:
http://www.prescriptionpc.com/TEST_n...ection=contact (this one works PERFECT)

http://www.prescriptionpc.com/TEST_n...ml#section=sms (this is one I am having problems with)

The code I have for my "sms" DIV is as follows:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. error_reporting (E_ALL ^ E_NOTICE);
  4.  
  5. $post = (!empty($_POST)) ? true : false;
  6.  
  7. if($post)
  8.  
  9. $from = stripslashes($_POST['from']);
  10. $to = stripslashes($_POST['to']);
  11. $carrier = stripslashes($_POST['carrier']);
  12. $message = stripslashes($_POST['message']);
  13.  
  14.  
  15. if ($carrier == "verizon") {
  16. $formatted_number = $to."@vtext.com";
  17. mail("$formatted_number", "Msg from Website", "$message"); 
  18. // Currently, the subject is set to "SMS". Feel free to change this.
  19.  
  20. echo '<div class="notification_error">'.$error.'</div>';
  21. }
  22.  
  23. else if ($carrier == "tmobile") {
  24. $formatted_number = $to."@tomomail.net";
  25. mail("$formatted_number", "SMS", "$message");
  26.  
  27. echo '<div class="notification_error">'.$error.'</div>';
  28. }
  29.  
  30. else if ($carrier == "sprint") {
  31. $formatted_number = $to."@messaging.sprintpcs.com";
  32. mail("$formatted_number", "SMS", "$message");
  33.  
  34. echo '<div class="notification_error">'.$error.'</div>';
  35. }
  36.  
  37. else if ($carrier == "att") {
  38. $formatted_number = $to."@txt.att.net";
  39. mail("$formatted_number", "SMS", "$message");
  40.  
  41. echo '<div class="notification_error">'.$error.'</div>';
  42. }
  43.  
  44. else if ($carrier == "virgin") {
  45. $formatted_number = $to."@vmobl.com";
  46. mail("$formatted_number", "SMS", "$message");
  47.  
  48. $error = '';
  49.  
  50. // Check name
  51.  
  52. if(!$from)
  53. {
  54. $error .= 'Please Enter Your Name.<br />';
  55. }
  56.  
  57. // Check recipient
  58.  
  59. if(!$to)
  60. {
  61. $error .= 'Please Enter Recipient Phone Number<br />';
  62. }
  63.  
  64. // Check message (length)
  65.  
  66. if(!$message)
  67. {
  68. $error .= "Please Type Your Message.<br />";
  69. }
  70.  
  71. {
  72. echo 'OK';
  73. }
  74.  
  75. }
  76. else
  77. {
  78. echo '<div class="notification_error">'.$error.'</div>';
  79. }
  80.  
  81. ?>
ANY help would be greatly appreciated!
Thanks!
-Bruce
Aug 28 '10 #1
2 1644
JKing
1,206 Expert 1GB
I am sorry but I don't see what is going wrong... I took a look at both pages, submitted each one and they both show a thank you message. What is it supposed to do and what is it not doing?
Aug 30 '10 #2
You beat me to it...I JUST finished up the new scripting last night and both forms work perfect now - thank you for looking at it for me!

Kind Regards,
Bruce
Aug 30 '10 #3

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

Similar topics

2
by: funkychicken818 | last post by:
This is the script. var reqTopCont; var reqBotCont; function changeTopContent(newUrl) { reqTopCont = false; // branch for native XMLHttpRequest object if (window.XMLHttpRequest) {
2
by: brakai295 | last post by:
Hi there, I need someone to customise an autocompletion AJAX script a little bit. This free script here (demo | info & download) offers you auto-completion when typing in a country's name. I...
2
by: tuktik | last post by:
Hello everyone, I want to notify user if he modifies some data in the form and leaves the page without saving. So I use onunload event to call ajax file to check if the data in the form elements...
2
by: willl69 | last post by:
Hi All, Ive been having a problem of late with one of my sites that uses PHP5 / Ajax. The problem is that periodically the ajax functions lock up and it gets stuck in the loading phase of the...
3
by: willl69 | last post by:
Hi All, Ive been having a problem of late with one of my sites that uses PHP5 / Ajax. The problem is that periodically the ajax functions lock up and it gets stuck in the loading phase of the...
1
by: helraizer1 | last post by:
Hi folks, I have an AJAX script to refresh a certain element in the page. The problem is that the element I need it to refresh is a dynamic image.. but the way I've done it inserts the raw image...
2
by: =?Utf-8?B?REo=?= | last post by:
I have a peculiar problem here that I did not have until I migrated from ASP.NET 2.0 to 3.5. I use a master page for my application. Because the master page uses update panels I have the...
8
by: cyqotiq | last post by:
First, let me state that this is not necessarily a Firefox problem, as I haven't fully tested in IE just yet. Second, let me state that this is not the typical "getElementById not working Firefox"...
7
by: mike57 | last post by:
The minimal AJAX script below works in Firefox, but not in IE, Opera, or Chrome. I could use some suggestions or referrals to resources that will help me get the script working in other browsers. ...
3
by: kkshansid | last post by:
in ajax script select box is repeated state 2 times district 2 times kindly suggest me to correct this error <html> <head> <script languphase="javascript" type="text/javascript"> var...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.