Below is my ajax call
$(document).ready(function() {
$("#blog").focusout(function() {
alert('Focus out event call');
alert('hello');
$.ajax({
url: '/homes',
method: 'POST',
data: 'blog=' + $('#blog').val(),
success: function(result) {
$.each(result, function(key, val) {
$("#result").append('<div><label>' + val.description + '</label></div>');
});
},
error: function() {
alert('failure.');
}
});
});
});
I am getting 'TypeError: invalid 'in' operand obj ' error in my console
In advance thank you
Mention a dataType attribute in your ajax call.It consider text by default.That's why not able to iterate on result
dataType:'json'
Because your result should be array or json
the 'result' in success function should be an array
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With