Php 成功响应时显示div
我试图在php数据成功发送到服务器后显示success div,只是更新了数据,但是没有显示div 有人能告诉我哪里出了问题吗。我环顾了一下堆栈溢出,尝试了许多不同的解决方案,但都没有成功Php 成功响应时显示div,php,jquery,html,ajax,Php,Jquery,Html,Ajax,我试图在php数据成功发送到服务器后显示success div,只是更新了数据,但是没有显示div 有人能告诉我哪里出了问题吗。我环顾了一下堆栈溢出,尝试了许多不同的解决方案,但都没有成功 <div id= "infomsg" style="display: none;">Updated Successfully! </div> $.ajax({ type: "POST", url: "validate.php", cache: false, dataType: "js
<div id= "infomsg" style="display: none;">Updated Successfully! </div>
$.ajax({
type: "POST",
url: "validate.php",
cache: false,
dataType: "json",
data: dataString,
success: function(Success){
$('#infomsg').show(Success)
}
});
if (isset($_POST))
{
$first=$_POST['first'];
$middle=$_POST['middle'];
$last=$_POST['last'];
$email=$_POST['email'];
$lives=$_POST['lives'];
$Gender=$_POST['Gender'];
$about=$_POST['about'];
$fav_track=$_POST['fav_track'];
$fav_bands=$_POST['fav_bands'];
$sql3 = "UPDATE user SET first='$first',middle='$middle',last='$last',email='$email',lives='$lives',Gender='$Gender', about='$about', fav_track='$fav_track', fav_bands='$fav_bands' WHERE `id`='".$_SESSION['id']."'";
$res3 = mysqli_query($mysqli,$sql3) or die(mysqli_error($mysqli));
//Writes the photo to the server
if($res3)
{
//Tells you if its all ok
echo '<div id= "infomsg" style="display: none;">Updated Successfully! </div>';
}else{
//Gives and error if its not
echo "Sorry, there was a problem updating the Information, Contact se7ern@se7ern.co.uk with REF:#1112-Validate.";
}
}
更新成功!
$.ajax({
类型:“POST”,
url:“validate.php”,
cache:false,
数据类型:“json”,
数据:dataString,
成功:功能(成功){
$('infomsg').show(成功)
}
});
国际单项体育联合会(国际单项体育联合会)
{
$first=$_POST['first'];
$middle=$_POST['middle'];
$last=$_POST['last'];
$email=$_POST['email'];
$lives=$_POST['lives'];
$Gender=$_POST['Gender'];
$about=$_POST['about'];
$fav_track=$_POST['fav_track'];
$fav_bands=$_POST['fav_bands'];
$sql3=“更新用户集first='$first',middle='$middle',last='$last',email='$email',lifes='$lifes',Gender='$Gender',about='$about',fav_track='$fav_track',fav_bands='$fav_bands',其中`id`='''''$_会话['id'.'”;
$res3=mysqli_query($mysqli,$sql3)或die(mysqli_error($mysqli));
//将照片写入服务器
如果(3美元)
{
//告诉你一切是否正常
echo“已成功更新!”;
}否则{
//如果不是,则给出和错误
echo“抱歉,更新信息时出现问题,请联系se7ern@se7ern.co.uk带参考号:#1112验证。“;
}
}
如果只想显示div,不要将参数传递给show()
方法,只需执行以下操作:
$('#infomsg').show();
如果您需要从服务器返回一些信息,则需要深入了解对象的成功。只需显示div:
$('#infomsg').show() 尝试确保首先输入success函数-放置一个警报()代码>块中的语句
如果可行,请尝试更改其CSS属性:
$('#infomsg').css('display', 'inline');
如果只想显示
,则不必在“show()
”方法中传递任何参数
您只需使用下面提到的方法即可:
<div id="infomsg" style="display: none;">Updated Successfully!</div>
$.ajax({
type: "POST",
url: "validate.php",
cache: false,
dataType: "json",
data: dataString,
success: function (Success) {
$('#infomsg').show();
}
});
更新成功!
$.ajax({
类型:“POST”,
url:“validate.php”,
cache:false,
数据类型:“json”,
数据:dataString,
成功:功能(成功){
$('#infomsg').show();
}
});
什么是“成功”返回?它是否返回HTML?你应该只显示div而不显示消息。是的。那么是html(成功)吗?那么,您正在用返回值替换div中的内容,对吗?警报甚至不起作用。我要发布我的php结尾吗?在那之前,试着独立运行php代码-试着放置一个echo'a'语句。你看到输出了吗?
<div id="infomsg" style="display: none;">Updated Successfully!</div>
$.ajax({
type: "POST",
url: "validate.php",
cache: false,
dataType: "json",
data: dataString,
success: function (Success) {
$('#infomsg').show();
}
});