遗漏的类型错误:b.replace不是一个函数
你好我得到在控制台AJAX文件未捕获的类型错误,即使一切正常......遗漏的类型错误:b.replace不是一个函数
的HTML是
<div id="deletepropertybutton"><a href = "editproperty.php?property_id=<?php echo $data['property_id'];?>" class="editpropertybutton">Edit</a></div>
的PHP是
$del_id = ($_POST['del_id']);
$delete = $con->prepare("DELETE FROM tbl_property WHERE property_id='$del_id'");
$delete->execute();
$delete2 = $con->prepare("DELETE FROM tbl_favorite_properties WHERE favorite_properties_property_id='$del_id'");
$delete2->execute();
和AJAX是
$(document).ready(function()
{
$('.deletepropertybutton').click(function()
{
event.preventDefault();
var del_id = $(this).attr('id');
var $ele = $(this).parent().parent();
$.ajax(
{
type: 'POST',
url: '../controllers/deleteproperty.php',
data:
{
del_id: del_id
},
success: function(data)
{
$.ajax(
{
type: 'POST',
url: "../controllers/managepropertiesajax.php",
success: function(data3)
{
$('#propertycounter').html("(" + data3 + ")");
}
});
$ele.fadeOut(1000).delay(1000).remove(1000);
}
});
});
});
我应该如何去修复这种错误..我有这个在其他Ajax文件也完整的错误代码是
遗漏的类型错误:b.replace不是一个函数
at Function.ga.matchesSelector (jquery.js:2)
at Function.r.filter (jquery.js:2)
at Ia (jquery.js:3)
at r.fn.init.remove (jquery.js:3)
at Object.success (deletepropertyajax.js:27)
at i (jquery.js:2)
at Object.fireWith [as resolveWith] (jquery.js:2)
at A (jquery.js:4)
at XMLHttpRequest.<anonymous> (jquery.js:4)
这里是文档jQuery.remove
。
在文档中,它是认为remove
需要一个可选参数,它是一个选择器。由于你的调用延迟1000
(数字),jQuery将其解释为导致问题的选择符(字符串)(数字没有名为replace
的函数)!
删除的remove
的parametter这样的:
$ele.fadeOut(1000)
.delay(1000)
.remove(); // no parametter for remove
如果你想保持淡出效果,使用回调(第二个可选parametter到delay
)是这样的:
$ele.fadeOut(1000, function() {
$ele.remove();
});
是这样可以修复它,但它也会消除淡出效果 – DragonFire
@downvoter why ??? –
这些downvoter只是downvote没有解释... stackoverflow应该揭示他们的身份,并强制他们给理由 – DragonFire
哪里变'B'? '.replace()'在哪里发生? –
没有变量b,它进入jquery文件...我已经从jquery站点下载了 – DragonFire
你得到了什么确切的错误? –