您可以做的是发送$ .post像这样:
$.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在你的
test.php
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_enpre($data); // echo to pass back to $.post .. json_enpre() in case of using json } if($x == "1") { // valid - submit $data['message'] = 'valid'; // pass the message as valid postecho json_enpre($data); }记得:
如果您要发布表单,请提交以添加
event.preventDefault()到您的javascript函数中以手动处理表单。在这里您可以找到更多关于它的信息。



