I know I must be missing something obvious, but I can't seem to see why my code/approach doesn't work. When I try to call an anonymous function upon success in my AJAX call (I'm just trying to grab an XML file), it never fires. If, however, I change the success to a mere alert('success!') This works fine. Can anyone shed light on why this is happening?
$("#target").click(function() {
alert( "Handler for .click() called." );
var part = document.getElementById('partname').value;
var url = "http://parts.igem.org/xml/part." + part;
alert(url);
$.ajax({
type: 'GET',
url: url,
dataType: 'xml',
success: function(response) {
console.log('response = '+response);
}
});
});
Again, using: success: alert('success');
In lieu of the anonymous function works fine. Completely puzzled over here. Thank you!