I have the following Ajax script to process a form within my DIV:
<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><block quote>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_newpage1.html#section=contact (this one works PERFECT)
http://www.prescriptionpc.com/TEST_newpage1.html#section=sms (this is one I am having problems with)
The code I have for my "sms" DIV is as follows:
==================================================
<?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