Jump to content

Pass PHP ID with Ajax request


Go to solution Solved by Ch0cu3r,

Recommended Posts

Hi guys,

 

I am trying to figure out how to pass PHP ID  (page.php?id= 'id' ") with ajax request.

 

Getting the ID and storing it into variable called "playlistsongid"

<?php 
  session_start();
  if(!isset($_GET['id'])) die("No id set"); ?>

<?php $playlistsongid = $_GET['id']; ?>
function setupyoutubesongarray(firstload) {
  $.ajax({
   'url': 'post.php',
   'async': false,
    success: function (response) {

        var posturl="post.php"; // needs to looks something like post.php?id=
        $.getJSON(posturl,function(data){
          youtubesongs = [];
          $.each(data.members, function(i,song){
            result = (song.SongUrl);
              youtubesongs.push(result);
            //ytplayer_playlist.push(result);
          });
          
          loadnextbatchfromsongsarray();
          if (firstload = 1) {
            ytplayer_render_player();
          }
        });
    }
  });
}

Any help would be much apreceated!

Link to comment
https://forums.phpfreaks.com/topic/286227-pass-php-id-with-ajax-request/
Share on other sites

  • Solution

You'd pass the id in the   url: like you do with a hyperlink

'url': 'post.php?id=id-here',

If your id is in javacript variable then use

'url': 'post.php?id=' + your_js_id_variable,
Edited by Ch0cu3r
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.