too long

I'm trying to send multiple variables to PHP using the following statement in jQuery:

jQuery:

$(document).ready(function () {
    $('.modalsend').click(function () {
        $('span.user-topicid').load('get_number_comments.php?topicid=' + $(this).data('topicid') + '&page=' + '<?=$_GET['page']?>');
    });
});

It works fine if I pass a single variable in the PHP file like so:

jQuery:

$('span.user-topicid').load('get_number_comments.php?topicid=' + $(this).data('topicid'))

However, when I try to pass &page=, it fails to pass anything to the PHP file which has the following variables to get the URL:

PHP (get_number_comments.php):

$numberid = mysql_real_escape_string($_GET['topicid']);
$page = mysql_real_escape_string($_GET['page']);

I think it's probably an issue with the markup in the jQuery with the additional &page= but not sure what could be causing it. Note that page is in the URL of the page with the first jQuery function.

NOTE: Issue has been resolved, it is best to get the URL first ($page = mysql_real_escape_string($_GET['page']);) and send the $page variable in a data attribute just like topicid - please refer to Variable value not passing into mySQL statement in Bootstrap Modal for further details on the solution

your problem is in this part '<?=$_GET['page']?>'

you can't pass a php code in the location, you either need to send the variable:

$('span.user-topicid').load('get_number_comments.php?topicid=' + $(this).data('topicid') + '&page=' + page);

or store the code in a variable and then send it:

 var pageVal='<?=$_GET["'+page+'"]?>';
 $('span.user-topicid').load('get_number_comments.php?topicid=' + $(this).data('topicid') + '&page=' + pageVal);

I believe Amin has already answered your question but I just wanted to add that according to the .load() documentation, you can pass your data as the second argument and it should handle the encoding. So you could do something like this:

var pageVal= <?=$_GET['page']?>;
var data = { "topicid": $(this).data('topicid'), "page": pageVal };
$('span.user-topicid').load('get_number_comments.php', data);