HTML代码:
标题:
文章:
发布
jquery 代码:
var title_input = "title="+$(".title_input").val();
var article_input ="article="+ $(".article").val();
$.post("release.php",{
title:title_input,
article:article_input
},function(result){
$(".load").remove();
if(1==result)
{
alert("已经成功插入");
}
else{
//alert(result);
console.log(result);
}
});
php 代码:
header("Content-Type:text/html;charset=utf-8");
print_r($_POST);
$title=addslashes($_POST['title']);
$article=addslashes($_POST['article']);
//$title="weishenme";
//$article="这篇文章内容为空";
if($title)
echo "$title ,$article";
else
echo "找不到变量";
chrome 调试结果
Request URL:http://localhost:63342/leaveN...
Request Method:POST
Status Code:200 OK
Remote Address:127.0.0.1:63342
Response Headers
view source
access-control-allow-credentials:true
access-control-allow-headers:accept
access-control-allow-headers:content-type
access-control-allow-headers:origin
access-control-allow-headers:authorization
access-control-allow-origin:http://localhost:63342
content-length:273
Content-Type:text/html;charset=utf-8
server:PhpStorm 10.0.3
vary:origin
X-Powered-By:PHP/5.6.27
Request Headers
view source
Accept:/
Accept-Encoding:gzip, deflate, br
Accept-Language:zh-CN,zh;q=0.8
Connection:keep-alive
Content-Length:177
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Host:localhost:63342
Origin:http://localhost:63342
Referer:http://localhost:63342/leaveN...
User-Agent:Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
X-Requested-With:XMLHttpRequest
Form Data
view source
view URL encoded
title:title=对方如果突然欢迎您
article:article=啊果然他好久没