I'm trying to use POST to retrieve some scripts on a wordpress site but I'm getting the following error
Uncaught TypeError: Cannot call method 'post' of undefined
Basically I load an external javascript file which loads a couple of scripts, then calls back to a function on the original page to execute a POST call to retrieve some data.
I've used this exact same script on a "regular" HTML based site, so I know it works elsewhere. jQuery is loaded as you can see, because I use .getScript to retrieve another file (which does load)
Now for the function retrieve_window(); located on the template file.
//template file that initially loads
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://localhost/Project1/js/retrieve_scripts.js"></script>
<div class="reserve_wrapper " id="resere_wrapper"></div>
<script>
function retrieve_window(){
$.post("http://localhost/Project1/windows/serve_window",function(data) {
$('#reserve_wrapper').html(data);
display_window();
});
}
</script>
Here's the get_scritps file that is loaded
//retrieve_scripts.js
jQuery(document).ready(function ($) {
$.getScript("http://localhost/project1/js/date.js", function() { }); //this script loads
retrieve_window(); //calls back to template file to make POST request
});
So basically the retrieve_window is a callback function to ensure the date.js script is properly loaded