0

I've read through the jQuery Mobile documentation on $.mobile.changePage() although I'm still stuck on knowing how to retrieve the posted data.

I have the code:

$.mobile.changePage( "videoplayer.asp", {
            type: "post", 
            data: data
        });

On the videoplayer.asp page I have some more jQuery that runs to setup a video player although I can't seem to access the posted data.

I've tried a few solutions, which are really just guesses:

$.get(data)
$.post(data)
data by itself
Jasper
  • 75,717
  • 14
  • 151
  • 146
Bankzilla
  • 2,086
  • 3
  • 25
  • 52

2 Answers2

1

You cannot access the POST data from the Javascript on videoplayer.asp, you can only access POST-data on the server (in your case in the asp code).

If you want to pass an parameter (say VideoId) to the javascript on videoplayer.asp I would recommend that you set it in the querystring of the URL.

Something like:

var videoId = 1000;
$.mobile.changePage("videoplayer.asp?videoId=" + videoId);

That way you can read it with your Javascript.

You can read more how to get query string values with Javascript here.

Community
  • 1
  • 1
Robin Andersson
  • 5,150
  • 3
  • 25
  • 44
0

You can use some .asp code to add the necessary POST data to your JavaScript.

Sorry I don't have much experience with .asp but here is how to do it in PHP:

<script>
var post_data = <?php echo json_encode($_POST); ?>;
</script>

This will save the POST data to a JavaScript object.

You can access GET variables in JavaScript though with the location.search property.

Jasper
  • 75,717
  • 14
  • 151
  • 146