I’m using jquery mobile in a phonegap application and I’m trying to pass a variable from a textbox in to the next page to do an xml traverse with the variable.
My page has this javascript to send the variable through but I don’t know how to retrieve it on the next page.
<script type="text/javascript">
$("#s-sur").live('pageinit', function() {
$("#search").click(function() {
$.mobile.changePage( "ssname.html", {
type: "post",
data: $("#search").serialize()
});
});
});
</script>
The
ssname.htmlfile will have to be parsed by a server-side language to get the POST variables. You can however access GET variables from JavaScript:and then for the
ssname.htmlpage:You could also just use a global variable to hold the information between pages:
Then on the
ssname.htmlpage you can just read thewindow.myCustomVariablevariable to do work. This works because the pages will occur in the same DOM, so thewindow.myCustomVariablevariable will exist for both pages.