yang dapat Anda lakukan adalah mengirim $.post seperti ini:
$.post("test.php", { "post1": "something", "post2":"somethingelse" }, // those will be sent via post to test.php
function(data){// the returned data
console.log(data.return1); // here just logging to the console. **optional**
console.log(data.return2);
// complete your process
}, "json"); // specifying the type as json also optional
di test.php
. Anda
foreach($_POST as $key=> $for) {
if(!empty($for) && $key != 'send' && $key != 'title') {
$usercheck = "SELECT email FROM users WHERE email = '$for'";
$usercheck = $db->query($usercheck);
if($usercheck->num_rows > 0) {$x="1"; continue;}
if($usercheck->num_rows == 0){$x="2"; break;}
}
}
if($x == "2") {$data['message'] = $for." is not a regestered email";
echo json_encode($data); // echo to pass back to $.post .. json_encode() in case of using json
}
if($x == "1") { // valid - submit
$data['message'] = 'valid'; // pass the message as valid post
echo json_encode($data);
}
Ingat:
Jika Anda memposting formulir, kirimkan untuk menambahkan event.preventDefault()
ke fungsi javascript Anda untuk menangani formulir secara manual. di sini
Anda dapat menemukan lebih banyak tentangnya.