JaySee
JaySee

Reputation: 351

Attempting to load page with url in GET

So I'm trying to load a page with a URL as a GET variable. Unfortunately, I keep getting a 404 from apache. Using JQuery, my syntax for the request is the following:

$.ajax({
    type: "GET",
    url: "page.php&url="+theURL,
    dataType: "xml",
    success: function(xml){
        loadFeed(xml);
    }
});

and the php for page.php is as follows:

<?php

domain="localhost";

header('Content-type: application/xml');

referer=$_SERVER['HTTP_REFERER'];

if(!stripos($referer, $domain)){
    print("BAD REQUEST");
    return;
}

$handle = fopen($_GET['url'], "r");
if ($handle) {
    while (!feof($handle)) {
        $buffer = fgets($handle, 4096);
        echo $buffer;
    }
    fclose($handle);
}
?>

Not sure what i'm doing wrong here.

Upvotes: 0

Views: 117

Answers (1)

Ibu
Ibu

Reputation: 43810

YOu have an error in your url:

$.ajax({
    type: "GET",
    url: "page.php&url="+theURL,  // Here
    dataType: "xml",
    success: function(xml){
        loadFeed(xml);
    }
});

should be:

$.ajax({
    ...
    url: "page.php?url="+theURL,  // Here
    ...
});

Note I used a question mark instead of ampersand. Also this might be a typo but you are missing the $ in front of variables

Upvotes: 3

Related Questions