In the success callback function of my AJAX post, I'm trying to call a function that's in another JS file
page1.html contains:
<head>
<link href="style.css" rel="stylesheet" type="text/css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="js/page2.js" type="text/javascript"></script>
<script>
$.ajax({
type: 'post',
url: '/dev/new/scripts/search.php',
dataType: 'json',
data: {"search_1":"<?php echo $item1; ?>","search_2":"<?php echo $item2; ?>"},
success: searchResults()
});
</script>
</head>
$.ajax({
type: 'post',
url: '/dev/new/scripts/search.php',
dataType: 'json',
data: {"search_1":"<?php echo $item1; ?>","search_2":"<?php echo $item2; ?>"},
success: searchResults()
});
page2.js contains:
$(document).ready(function() {
function searchResults () {
stuff...
}
});
The error firebug is giving me is: "ReferenceError: searchResults is not defined"
searchResultsis inside your ready function, hidden from the global scope.