CodeDezk CodeDezk - 1 year ago 86
Ajax Question

PHP cannot pass two parameter to another php using ajax

I need to call php and get data from another server and I am using proxy.php to call from ajax.


header('Content-type: application/json');
echo $json;

And my code looks

function scanFunction(){

var url="http://address/scan.php?user=user1&video=video1";

url = 'proxy.php?url='+url;


url: url,
type: "POST",
data: {

dataType: "JSON",
success: function (jsonStr) {
var obj = jsonStr;
console.log(" error...");




And this code works fine when I use one parameter to the url passing to proxy.php where as second argument missing

That is

echo $url;
inside proxy.php print

event I pass two argument like,

That is second argument video missing inside proxy.php and so I am not getting expected result.

Answer Source

You may be having issues with your GET variables in the GET['url'] variable.

Try encoding your url when you send it to proxy.php to avoid such issues.

var url = encodeURIComponent("http://address/scan.php?user=user1&video=video1");
url = 'proxy.php?url='+url;

Then on the PHP side you need to decode it.

if (is_string($url)) {
    $url = urldecode($url);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download