Jump to content

cURL & jQuery AJAX?


MySQL_Narb

Recommended Posts

In the PHP section because I believe the error is on the PHP side.

 

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.

Link to comment
https://forums.phpfreaks.com/topic/274751-curl-jquery-ajax/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.