有问题我猜它与网址或某种东西有关。我只是看不出它是什么。我发布了jquery部分,也许我有错误或非常过时了?
它只是没有附加到我的实际链接,哪里会有php文件。
url.127.0.0.1 - - [07 / Jan / 2016:20:54:19 -0500]" POST /projectBox/php/add_box.php HTTP / 1.1" 200 224 " http://localhost/projectBox/?txtBox=test&txtDetail=test" " Mozilla的/ 5.0 (X11; Ubuntu; Linux x86_64; rv:43.0)Gecko / 20100101 Firefox / 43.0"
$('#addProject').click(function(event)
{
var dataProject = $('form[name="frmAddProject"]').serialize();
$.ajax({
data: dataProject,
type: 'POST',
url: './php/add_box.php',
dataType: 'html',
success: function(data)
{
if(data == 1)
{
alert("réusssi");
}
else if (data == 0) {
alert("erreur d'enregistrement!");
}
},
error: function(jqxhr, ajaxOptions, errorThrown)
{
console.log(dataProject);
$('#error').text("ERROR : " + jqxhr.status + " " + errorThrown + " " + error);
$('#error').toggle();
//$('#error').animate({width: 'toggle'}).delay(5000).hide(1);
}
});
});
这是我的html标签
<form name="frmAddProject">
<div id="input_dialogue" class="hide">
<h3>Add project Box</h3>
<hgroup>
<label>Title</label>
<input id="txtBox" name="txtBox">
</hgroup>
<hgroup>
<label>Description</label>
<input id="txtDetail" name="txtDetail">
</hgroup>
<button id="addProject">
Add
</button>
</div>
</form>
这是php部分
include('./connect.php');
$myBox = $_POST['txtBox'];
$myDetail = $_POST['txtDetail'];
$sql = "INSERT INTO pbo_projects('pbo_title', 'pbo_description')
VALUES ('".$myBox."', '".$myDetail."')";
if($mysqli->query($sql) === TRUE)
{
$mysqli->close();
return "1";
}
else
{
$mysqli->close();
return "0";
}
编辑2ND错误* 我还创建了一个函数来获取不同的项目,我在我的JQuery中获得了500个状态代码,但是当我从数据中提醒.error时,如果有任何帮助,我现在就不会这样做。它似乎给了我一些我无法阅读的Jquery东西。
警报显示:
function(){if(h){var c = h.length;!function 克(B){n.each(B,功能(B,C){风险 d = n.type(c)中;&#34;功能&#34; === d a.unique&安培;&安培; k.has(C)|| h.push(C):C&安培;&安培; c.length&安培;&安培;&#34;串&#34; == d&安培;&安培;克(C)})}!(参数),d F = h.length:b&安培;&安培;(E = C,J(b)中)}返回 此}
有jquery部分:
function loadProjects()
{
$.ajax(
{
type: 'GET',
dataType: 'json',
url: './php/load_projects.php',
success: function(data)
{
alert(data);
},
error:function(data)
{
alert(data.error);
console.log(data.status);
}
});
}
load_projects.php part
include('./connect.php');
$sql = "SELECT pbo_title, pbo_description
FROM pbo_projects ";
$result = $mysqli->query($sql); #line 8 says Use of undefined constant \xc2\xad - assumed '\xc2\xad' ## this is my access.log
$titles = array();
while ($row = $result->fetch_assoc())
{
$titles[] = array('title' => $row['pbo_title'], 'description' => $row['pbo_description']);
}
echo json_encode($titles);
再想一想?
答案 0 :(得分:0)
你可以尝试:
$myBox = $_GET['txtBox'];
$myDetail = $_GET['txtDetail'];