87,910
社区成员
发帖
与我相关
我的任务
分享
$.ajax({
url: 'http://localhost/index.php',
type: 'post',
data: $('#div :input'),
dataType: "json",
success: function(data) {
alert(data);
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
php代码:
if($_SERVER['REQUEST_METHOD'] == 'POST') {
$json = array();
if(isset($_POST['title'])){
$json['success'] = 'yes';
} else {
$json['error'] = 'no';
}
echo json_encode($json);
}