$(document).ready(function(){
$("#pop1").click(function(){
$("#shadow").fadeIn("normal");
$("#form1").fadeIn("normal");
$("#firstname").focus();
});
$("#cancel_hide").click(function(){
$("#form1").fadeOut("normal");
$("#shadow").fadeOut();
});
$("#insert").click(function(){
fname =$("#firstname").val();
lname =$("#lastname").val();
addr =$("#adres").val();
city =$("#city").val();
state =$("#state").val();
zip =$("#zip").val();
tel =$("#phone").val();
email =$("#email").val();
ip =$("#ip").val();
source =$("#source").val();
date =$("#date").val();
$.ajax({
type : "POST",
url : "save.php",
data : "fname="+fname+"&lname="+lname+"&addr="+addr+"&city="+city+"&state="+state+"&zip="+zip+"&tel="+tel+"&email="+email+"&ip="+ip+"&source="+source+"&date="+date,
success : function(html){
if(html=='true')
{
$("#form1").fadeOut("normal");
$("#shadow").fadeOut();
$("#profile").html("<a href='logout.php' id='logout'>Logout</a>");
}else{
$("#add_err").html("Wrong username or password");
}
},
beforeSend:function(){
$("#add_err").html("Loading...")
}
});
return false;
});
});
我的index.php文件是obove
如何将save.php中出现的错误打印到index.php
中例如,如何在index.php中将此输出转换为div echo“Hata No:”。mysql_errno()。“”HataMesjjý:“。mysql_error();
答案 0 :(得分:0)
由于PHP返回HTML,你可以这样写出来,假设你有一个id =“result”的div -
if(html=='true') {
$('#result').text(html);
// rest of your code here
当然,您可能需要检查HTML中返回的内容,以便了解是否要显示此信息。