1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > php获取ajax data HTML 获取 PHP 接口数据(ajax)

php获取ajax data HTML 获取 PHP 接口数据(ajax)

时间:2019-06-14 13:09:39

相关推荐

php获取ajax data HTML 获取 PHP 接口数据(ajax)

HTML 部分

Untitled Document

function checkemail(){

if($('#email').val() == ""){

$('#msg').html("please enter the email!");

$('#email').focus;

return false;

}

if($('#address').val() == ""){

$('#msg').html("please enter the address!");

$('#address').focus;

return false;

}

ajax_post();

}

function ajax_post(){

$.post("http://xxx.xxx.xxx.xxx/action.php",{email:$('#email').val(),address:$('#address').val()},

function(data){

//$('#msg').html("please enter the email!");

//alert(data);

$('#msg').html(data);

},

"text");//这里返回的类型有:json,html,xml,text

}

email

address

PHP 部分

header('Access-Control-Allow-Origin:*');//跨域

$email = $_POST["email"];

$address = $_POST["address"];

//echo $email;

//echo $address;

echo "success";

?>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。