Php 我没有从我的AJAX部分得到任何响应?
在上面的部分中,响应部分不起作用,即错误类DIV在编辑时不显示任何响应 编辑_cat.phpPhp 我没有从我的AJAX部分得到任何响应?,php,ajax,jquery,Php,Ajax,Jquery,在上面的部分中,响应部分不起作用,即错误类DIV在编辑时不显示任何响应 编辑_cat.php function check_cat_to_save(){ $.ajax({ type:'POST', url:'edit_cat.php', data:"cat_name="+$('#cat_name').val()+"&cat_id="+$('#cat_id').val()+"&cat_desc="+$('#cat_desc'
function check_cat_to_save(){
$.ajax({
type:'POST',
url:'edit_cat.php',
data:"cat_name="+$('#cat_name').val()+"&cat_id="+$('#cat_id').val()+"&cat_desc="+$('#cat_desc').val()+"&cat_publish="+$('#cat_publish').val(),
success:function(response){
if(response=='6'){$('#error').css({'color':'red','display':'block'}).html('Category already exists!')}
else if(response=='7'){$('#error').css({'color':'#0c0','display':'block'}).html('Sucessfully edited category!')}
else if(response=='8'){$('#error').css({'color':'red','display':'block'}).html('OOPS Something went wrong!')}
else if(response=='9'){$('#error').css({'color':'red','display':'block'}).html('Please Fill all the feilds!')}
else {$('#error').css({'color':'red','display':'block'}).html('Please Fill all the feilds!')}
}
});
};
你能从Chrome或Firefox上的开发者控制台获取PHP响应吗?你是否尝试过通过Chrome或Firefox的firebug进行调试?是的,我尝试过,但没有任何效果
function check_cat_to_save(){
$.ajax({
type:'POST',
url:'edit_cat.php',
data:"cat_name="+$('#cat_name').val()+"&cat_id="+$('#cat_id').val()+"&cat_desc="+$('#cat_desc').val()+"&cat_publish="+$('#cat_publish').val(),
success:function(response){
if(response=='6'){$('#error').css({'color':'red','display':'block'}).html('Category already exists!')}
else if(response=='7'){$('#error').css({'color':'#0c0','display':'block'}).html('Sucessfully edited category!')}
else if(response=='8'){$('#error').css({'color':'red','display':'block'}).html('OOPS Something went wrong!')}
else if(response=='9'){$('#error').css({'color':'red','display':'block'}).html('Please Fill all the feilds!')}
else {$('#error').css({'color':'red','display':'block'}).html('Please Fill all the feilds!')}
}
});
};
<?php
$cat_id = mysql_real_escape_string($_POST["cat_id"] );
$cat_name = mysql_real_escape_string($_POST["cat_name"] );
$cat_desc = mysql_real_escape_string($_POST["cat_desc"] );
$cat_publish = mysql_real_escape_string($_POST["cat_publish"] );
if(!empty($cat_name) && !empty($cat_desc)){
$cat_check_name = "SELECT * from categories WHERE
cat_name = '$cat_name' and cat_id <> '$cat_id' ";
$result_check_name = mysql_query($cat_check_name);
$num_rows_all = mysql_num_rows($result_check_name);
if($num_rows_all>0) {
echo '6';
exit();
}
//if categories are not out of number
else {
$sql = "UPDATE categories SET
cat_name = '{$cat_name}',
cat_description = '{$cat_desc}',
active = '{$cat_publish}'
WHERE
cat_id = {$cat_id}
";
$result_set = mysql_query($sql);
if($result_set) echo '7';
else echo '8';
}
}
else echo '9';
?>