Saturday, May 11, 2024
 Popular · Latest · Hot · Upcoming
72
rated 0 times [  74] [ 2]  / answers: 1 / hits: 24654  / 11 Years ago, fri, march 29, 2013, 12:00:00

I have a Javascript file that submits a form and loads an alert etc. Now I want to add functionality to call or get a .php file, I tried using $.get(mail.php); but it doesn't seem to work.



Javascript Code:





$('#myform').on('submit', function(e){
e.preventDefault();
$.get($(this).attr('action') + $(this).serialize());
alert(Thank You! nTop Up for: <?php echo $username ?> Purchased Successfully);
$.get(mail.php); //this is the added part to get mail.php//
location.reload();


PHP - mail.php:



<?php

$to = [email protected];

$headers = From: website mail rn;

$email_body = has just toped up his account.n.

$email_subject = User Topup Alert;

mail($to,$email_subject,$email_body,$headers);

?>

More From » php

 Answers
13

I think you can try load():



$(#mailDiv).load('mail.php');


According to me $.get and $.post are to send the data. You cannot include files using this.


[#79248] Thursday, March 28, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
alvin

Total Points: 55
Total Questions: 101
Total Answers: 109

Location: Sudan
Member since Tue, Aug 3, 2021
3 Years ago
;