Forum Moderators: open
<script type="text/javascript">
function someAjax() {
/* an ajax call here.. when the ajax comes back successful it returns true or if its unsuccessful it returns false */
return ;
}
</script>
<a href="page.php" onclick="return someAjax()">Anchor</a>
.... a click on the anchor will do this in this order
-act like its loading a page (the important part)
-make the ajax call
-when the ajax call is successful it follows the link
-if the ajax is unsuccessful, nothing happens
i'm trying to duplicate that with the click of a <button> or the change of an input field. the part i'm missing is when the user clicks the button the browser just sits and waits for the ajax call to finish then on success it starts to load the new page.
is it possible to make the browser act like its loading a page? or mimic an anchor click in javascript? i tried wrapping an anchor around a button, but that doesn't work in IE. I'm using Prototype if that helps/hurts.
document.location = 'page.php';
You never want to say something like "well this browser does it this way" because you never know if that will be the same behavior on another browser, perhaps another version, or whatever the case may be. You always want to know exactly what is going to happen and when. Doing it the way I explain should achieve this effect.
document.body.style.cursor = 'wait' ;
but if the body doesn't fill the window, its the arrow cursor in the non-body part of the window. whats the proper way to do this?
...but back to my original question, is there a way to maybe create a fake link with js, then have javascript perform a 'click' action on it so the page acts like its loading. then my script would do its thing and return true or false to the link so its followed or not.