Q: How to pass Javascript variables inside a URL? AJAX i am trying to pass the values of accesstoken and pageid inside the url that i use. Any ideas how to do it correctly? 
<script type="text/javascript">   
function makeUrl() {
    var accesstoken = "12345679|bababashahahhahauauuaua";
    var pageid =  "<?php echo $page_id;?>";
 $.ajax(
  {
    url: 'https://graph.facebook.com/?pageid/?access_token='+pageid+accesstoken,
 statusCode: {......


A: You can also use the "data" setting.  This will convert it to a query string.  
<script type="text/javascript">   
function makeUrl() {
    var accesstoken = "12345679|bababashahahhahauauuaua";
    var pageid =  "<?php echo $page_id;?>";
 $.ajax(
  {
    url: 'https://graph.facebook.com/',
    data: 'pageid='+pageid+'&access_token='+accesstoken
 statusCode: {......


A: Change 
url: 'https://graph.facebook.com/?pageid/?access_token='+pageid+accesstoken,

to
url: 'https://graph.facebook.com/?pageid='+pageid+'&access_token='+accesstoken,


A:  'https://graph.facebook.com/?pageid='+pageid+'&access_token='+accesstoken


A: You can create your url using:
function makeUrl() {
  var accesstoken = '12345679|bababashahahhahauauuaua';
  var pageid =  'example'
  return 'https://graph.facebook.com/?pageid=' + pageid + '&access_token=' + accesstoken;
}

And then pass it to your AJAX function.
function doAjax(_url) {
  return $.ajax({
    url: _url,
    type: 'GET'
  });
}

doAjax(makeUrl());

And now an elegant way to handle your success callback:
doAjax(makeUrl()).success(function() {
  // this will be executed after your successful ajax request
});

