I am having a little bit of trouble here. I have a call that returns some JSON, that is well-formed. I checked it on JSON Lint.
JSON: {"facilities":[{"facilityId":"123","facilityName":"Pizza Hut"}]}
I am able to see that data in my alert box with this code:
$(function () {
var availableTags = [
// TODO
];
$("#tags").autocomplete({
source: availableTags
});
$("#tags").focusout(function () {
var result = null;
$.ajax({
beforeSend: function() {
alert("Testing");
},
url: "FacilitiesAsync",
success: function(data) {
result = data;
},
complete: function () {
alert(result);
}
});
});
});
However, when I try this code I don't ever see the processFacilities function ever fire. I am not sure what I am doing incorrectly. The $getJSON DOES work but the callback function is never executed.
$.getJSON('FacilitiesAsync','sourceDb=sampleDb',processFacilities);
function processFacilities(data) {
var infoHtml = '';
$.each(data, function(facilities, facilityInfo) {
infoHtml += '<p>Facility: ' + facilityInfo + '<br></p>';
}); // end of each
$('#info').html(infoHtml);
};
I am not trying to run both of these at the same time. I commented one out while I test the other. These scripts are within a block in my MVC4 application.
My div
<div id="info"></div>