I'm trying to do an HTTP post request. My server is running a php script with code here
<?
$siteurl = $_REQUEST['address'];
$postdata = '';
$fakeua = 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; Trident/5.0)';
$ch = curl_init($siteurl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $fakeua);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
?>
And I'm calling this in my JS like this
$.ajax({
url: 'http://localhost/server.php',
type: 'POST',
data: {
address: urlToPost
},
success: function(response) {
window.console.log(response);
}
});
Is this correct? Should this work? It seems I'm getting a 200 OK from the request, but something isn't right because I'm the website I'm doing a POST request to isn't showing it. I am forming my url through concatenation, which should be fine as long as a I am concatenating it right, right? Or should the paramaters be passed in?
urlToPost += "&s=" + sessionID + "&a[0]=" + "Girls" + "&t[0]=" + "Laura" + "&i[0]=" + ts2 + "&o[0]=E" + "&r[0]=" + "&l[0]=" + "&b[0]=Album" + "&n[0]=" + "&m[0]=";