Ajax Script problem...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bruce1969
    New Member
    • Aug 2010
    • 2

    Ajax Script problem...

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

    Code:
      <script type="text/javascript">                                         
       // we will add our javascript code here           
       
    $(document).ready(function(){
    $("#ajax-contact-form").submit(function(){
    
    var str = $(this).serialize();
    
       $.ajax({
       type: "POST",
       url: "contact.php",
       data: str,
       success: function(msg){
        
    $("#note").ajaxComplete(function(event, request, settings){
    
    if(msg == 'OK') // Message Sent? Show the 'Thank You' message and hide the form
    {
    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>';
    $("#fields").hide();
    }
    else
    {
    result = msg;
    }
    
    $(this).html(result);
    
    });
    
    }
    
     });
    
    return false;
    
    });
    
    });
    
     </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:

    Code:
    <?php
    
    error_reporting (E_ALL ^ E_NOTICE);
    
    $post = (!empty($_POST)) ? true : false;
    
    if($post)
    
    $from = stripslashes($_POST['from']);
    $to = stripslashes($_POST['to']);
    $carrier = stripslashes($_POST['carrier']);
    $message = stripslashes($_POST['message']);
    
    
    if ($carrier == "verizon") {
    $formatted_number = $to."@vtext.com";
    mail("$formatted_number", "Msg from Website", "$message"); 
    // Currently, the subject is set to "SMS". Feel free to change this.
    
    echo '<div class="notification_error">'.$error.'</div>';
    }
    
    else if ($carrier == "tmobile") {
    $formatted_number = $to."@tomomail.net";
    mail("$formatted_number", "SMS", "$message");
    
    echo '<div class="notification_error">'.$error.'</div>';
    }
    
    else if ($carrier == "sprint") {
    $formatted_number = $to."@messaging.sprintpcs.com";
    mail("$formatted_number", "SMS", "$message");
    
    echo '<div class="notification_error">'.$error.'</div>';
    }
    
    else if ($carrier == "att") {
    $formatted_number = $to."@txt.att.net";
    mail("$formatted_number", "SMS", "$message");
    
    echo '<div class="notification_error">'.$error.'</div>';
    }
    
    else if ($carrier == "virgin") {
    $formatted_number = $to."@vmobl.com";
    mail("$formatted_number", "SMS", "$message");
    
    $error = '';
    
    // Check name
    
    if(!$from)
    {
    $error .= 'Please Enter Your Name.<br />';
    }
    
    // Check recipient
    
    if(!$to)
    {
    $error .= 'Please Enter Recipient Phone Number<br />';
    }
    
    // Check message (length)
    
    if(!$message)
    {
    $error .= "Please Type Your Message.<br />";
    }
    
    {
    echo 'OK';
    }
    
    }
    else
    {
    echo '<div class="notification_error">'.$error.'</div>';
    }
    
    ?>
    ANY help would be greatly appreciated!
    Thanks!
    -Bruce
    Last edited by Niheel; Aug 28 '10, 10:01 PM. Reason: please use code tags to display code
  • JKing
    Recognized Expert Top Contributor
    • Jun 2007
    • 1206

    #2
    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?

    Comment

    • Bruce1969
      New Member
      • Aug 2010
      • 2

      #3
      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

      Comment

      Working...