<select id="news_type" >新闻类型
<option value="1">推荐</option>
<option value="2">科技</option>
<option value="3">文学</option>
<option value="4">图片</option>
</select>
<label for="news_title">新闻标题</label>
<input type="text" id="news_title" name="news_title" />
<label for="news_content">新闻内容</label>
<textarea id="news_content" name="news_content" ></textarea>
<label for="news_source">新闻来源</label>
<input type="text" id="news_source" name="news_source" />
<label for="news_image">新闻图片</label>
<input type="text" id="news_image" name="news_image" />
<label for="publish_time">发布时间</label>
<input type="text" id="publish_time" name="publish_time" />
<input type="button" value="添加" id="add" />$(function(){
$("#add").on("click",function(){
$.ajax({
type:"POST",
url:"add_handler.php",
dataType:"json",
data:{
type:$("#news_type").val(),
title:$("#news_title").val(),
content:$("#news_content").val(),
source:$("#news_source").val(),
image:$("#news_image").val()
},
success:function(data){
if(data){
console.log(data);
}else{
alert("error");
}
},
error:function(jqXHR){
alert("发生错误:"+jqXHR.status);
}
});
});
});<?php
//require_once("../connect.php");
//添加
$type = $_POST['type'];
$title = $_POST['title'];
$content = $_POST['content'];
$source = $_POST['source'];
$image = $_POST['image'];
$time = time();
//echo $type;
?>请问我的代码写错了,为什么在我本地后台PHP取不到数据。前台已经成功发送数据后台一直报错把代码发给别人的环境看过,别人能取到数据。请问是我本地的环境问题吗?装的是wamp集成开发包
添加回答
举报
0/150
提交
取消