When I click the submit button in the following form, my jQuery GET function is called, but the callback is not. Any ideas?
<body>
<form id="searchbox">
<input type="text" name="q" size="60" value="Search ..." />
<input type="submit" value="Find it!">
</form>
<div id="result"><div>
<script>
$("#searchbox").submit(function(event) {
event.preventDefault()
$.get("http://localhost:8080/more/stuff/here",
function(data) {
alert(data);
}
);
});
</script>
The page that you call in your
$.getmust belong to the same origin (it has been already mentioned here). Moreover, the callback function is called only on success. This means that if you call a page and you are unauthorized (401) or the page cannot be found (404) the callback function will not be called.