So I have my PHP code here:

$r = new HttpRequest('https://api.worldoftanks.com/wot/auth/login/', HttpRequest::METH_POST);
$r->addPostFields(array('application_id' => 'e991ff783ae65f1ceefd1036211e5772', 'redirect_uri' => 'http://www.wotclanbuilder.com', 'nofollow' => 1));
try{
    $result = $r->send()->getBody();
    $json = json_decode($result);
    $url = json_encode($json->data->location);
    echo $url;
}
catch (HttpException $ex) {
    echo $ex;   
}

and my Ajax code here:

// AJAX Code To Submit Form.
$.ajax({
type: "POST",
url: "functions/signup-sql.php",
data: dataString,
cache: false,
success: function(result){
    console.log(result);
}

When I run the PHP code by itself it echos this:
"https:\/\/na.wargaming.net\/id\/openid\/?openid.assoc_handle=%7BHMAC-SHA1%7D%7B566a9b22%7D%7BqJXljw%3D%3D%7D&openid.ax.if_availab.... blah blah blah basically just one big long url.

But when I run the ajax code it logs all the code in my index.php instead of that long url. The code that makes up the index page I should say. I'm just not understanding why. Any help is appreciated :)

Recommended Answers

All 2 Replies

What do you mean when you say that it "logs all the code"?

Have you tried to do:

exit( var_dump( $url ) );

exit( var_dump( $ex ) );

Just to see what is returned?

I meant it console.log()'s all the code in index.php.

Basically when I check the console I see this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><script type="text/javascript">/* <![CDATA[ */Math.random=function(a,c,d,b){return function(){return 300>d++?(a=(1103515245*a+12345)%b,a/b):c()}}(1403227717,Math.random,0,1<<21);(function(){function b(){try{if(top.window.location.href==c&&!0!=b.a){var p=document.createElement('a');p.href=c;c='http%3A%2F%2F'+p.hostname+p.pathname+'%2F';var a=-1!=navigator.userAgent.indexOf('MSIE')?new XDomainRequest:new XMLHttpRequest;a.open('GET','http://1.2.3.4/cserver/clientresptime?cid=CID10890081.AID1453411974.TID11&url='+c+'&resptime='+(new Date-d)+'&starttime='+d.valueOf(),!0);a.send(null);b.a=!0}}catch(e){}}var d=new Date,a=window,c=document.location.href,f='undefined';f!=typeof a.attachEvent?a.attachEvent('onload',b):f!=typeof a.addEventListener&&a.addEventListener('load',b,!1)})();/* ]]> */</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>1st Armored Division</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<link href="css/css-reset.css" rel="stylesheet" type="text/css" />
<link href="css/header.css" rel="stylesheet" type="text/css" />
<link href="css/background.css" rel="stylesheet" type="text/css" />
<link href='https://fonts.googleapis.com/css?family=PT+Sans:400,400italic,700,700italic' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="functions/login.js"></script>
</head>

<body>
<!--Creation of header-->
<div id="header">
    <div id="register-container">
        <!--Sign Up-->
        <div id="signup" style="margin-right: 10px"><a href="/signup.php">Sign Up</a></div>

        <!--Sign-In section-->
        <form class="registerForm">       
                <!--Sign In-->
                <input type="button" id="submit" value="LOGIN"/>
                <input class="registerInput" id="username" type="text" placeholder="Username">
                <input class="registerInput" id="password" type="password" placeholder="Password" style="margin-right: 10px">

                <!--Login Error-->
                <div id="loginError" style="margin-right: 10px"></div>
        </form>
    </div>
</div>

</body>
<script type="text/javascript" src="javascript/animations.js"></script>
</html>

I tried "exit" and it had the same effect.

Sorry for the late reply I've been out of town for some time.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.