Reputation: 4082
Hi I am getting an uncaught type error in ajax file in console, even though everything is working properly...
the html is
<div id="deletepropertybutton"><a href = "editproperty.php?property_id=<?php echo $data['property_id'];?>" class="editpropertybutton">Edit</a></div>
the php is
$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();
and ajax is
$(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);
}
});
});
});
how should i go about fixing this kind of error.. i am having this in other ajax files also the full error code is
Uncaught TypeError: b.replace is not a function
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)
Upvotes: 6
Views: 16971
Reputation: 31692
Here is the docs to jQuery.remove
.
In the docs it sais that remove
expects an optional parameter which is a selector. Since you are calling it with a delay 1000
(number), jQuery excpects a selector (string) which is causing the problem (numbers don't have a function called replace
).
Remove the parameter of remove
like this:
$ele.fadeOut(1000)
.delay(1000)
.remove(); // no parameter for remove
If you want to keep the fadeout effect use the callback (second optional parameter to fadeout
) like this:
$ele.fadeOut(1000, function() {
$ele.remove();
});
Upvotes: 6