I'm trying to hide the parent of an input
after performing my Ajax call but it's not working for some reason, that is no effect happens and the parent is not hidden.
Here's my JQuery snippet:
$( ".getqty" ).mouseover(function() {
var split = this.id.split(":");
var color = split[0];
var size = split[1];
var prodID = split[2];
$.ajax({ //create an ajax request to loadstuff.php
type: 'POST',
url: 'includes/loadstuff.php',
dataType: 'html', //expect html to be returned
data:'color='+color+'&size='+size+'&prodID='+prodID,
success: function(response){
$(this).parent().hide(); //Problematic part
},
error:function (xhr, ajaxOptions, thrownError){
alert(thrownError);
}
});
});
This is my HTML:
<a href='#'>
<input class='getqty id='a:b:c' type='text'>
</a>
What I'm trying to do might seem pointless but it's actually me trying to understand why hiding the parent does not work on hover.
However I tried the following and hid the parent before the ajax call and it worked. I don't understand why.
$( ".getqty" ).mouseover(function() {
var split = this.id.split(":");
var color = split[0];
var size = split[1];
var prodID = split[2];
$(this).parent().hide(); //Moved it here and it works. But I need it after the ajax call
$.ajax({ //create an ajax request to loadstuff.php
type: 'POST',
url: 'includes/loadstuff.php',
dataType: 'html', //expect html to be returned
data:'color='+color+'&size='+size+'&prodID='+prodID,
success: function(response){
},
error:function (xhr, ajaxOptions, thrownError){
alert(thrownError);
}
});
});