我正在尝试使用AJAX和jQuery $ .post将一些数据插入到mySQL数据库中。我尝试测试功能如下
index.html:代码片段(已经为许多其他函数使用jQuery)
$.post(
"updateDatabase.php",
{ name: "Zara" },
function(data) {
//$('#stage').html(data);
alert('Success');
}
);
updateDatabase.php
<?php
if( $_REQUEST["name"] ) {
$name = $_REQUEST['name'];
echo "Welcome ". $name;
echo "<script>alert('Im here')</script>";
}
?>
我得到的是一个带有“成功”的警报而没有别的(这是$ .post的回调函数)。我已经研究了很多,发现了一些相似但不同的问题。但是我的问题没有解决,因为这个特定问题没有令人满意的解决方案。
答案 0 :(得分:1)
您正在回显字符串uint8x16_t b = {0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14};
uint8x16_t c = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15};
。所以,
你能做的是:
echo "alert('Im here')";
并在php:
function(data) {
alert('Success: '+data);
// outputs: Success: Welcome Zara I'm here
}
答案 1 :(得分:0)
更改此
echo "alert('Im here')";
到
echo "Im here";// no need of alert.
function(data) {
alert(data);
^// will alert Im here
}
您也可以使用
.done(function() {
alert("Success");
})
最终代码
$.post( "example.php", function() {
alert( "success" );
})
.done(function() {
alert( "second success" );
})
答案 2 :(得分:0)
尝试使用json作为返回数据的安全方式
260,310,570,600 ...