jQuery AJAX return isn't returning PHP data?
I got my index page:
- <html>
- <head>
- <title>YTBypass</title>
- <script type="text/javascript" src="jquery.js"></script>
- <script type="text/javascript">
- $(document).ready(function(){
- requestPage();
-
- $('a[href]').click(function( e ){
- e.preventDefault();
-
-
- url = $(this).attr('href');
- url = (url == '/') ? 'http://www.youtube.com' : url;
-
- requestPage(url);
- });
-
- function requestPage(pageURL){
- $('#loading').show(1500);
-
- //request page
- $.ajax({
- url: 'getpage.php?page='+ pageURL
- }).done(function( retrn ){
- $('#loading').hide(0);
-
- if(retrn == 'fail'){
- alert('Failed to request page.');
- }else{
- alert(retrn);
- $('#content').html(retrn);
- }
- });
- }
- });
- </script>
- </head>
- <body>
- <div id="loading" style="display:none;">
- <b><font size="4">Your request is loading...</font></b>
- </div>
- <div id="content">
-
- </div>
- </body>
- </html>
As you can see, it calls this page upon loading:
- <?php
- $url = (!isset($_GET['page']) || empty($_GET['page'])) ? 'http://www.youtube.com' : $_GET['page'];
- //initiate
- $ch = curl_init();
- //set cURL data
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- //execute & close
- $page = curl_exec($ch);
- curl_close($ch);
- echo $page;
- ?>
- applesauce
But for some reason, it doesn't seem to grab the data from the $page variable that the PHP code echoes out. It only returns applesauce.