So I have my PHP code here:

$r = new HttpRequest('', HttpRequest::METH_POST);
$r->addPostFields(array('application_id' => 'e991ff783ae65f1ceefd1036211e5772', 'redirect_uri' => '', 'nofollow' => 1));
    $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.
type: "POST",
url: "functions/signup-sql.php",
data: dataString,
cache: false,
success: function(result){

When I run the PHP code by itself it echos this:
"https:\/\/\/id\/openid\/?openid.assoc_handle=%7BHMAC-SHA1%7D%7B566a9b22%7D%7BqJXljw%3D%3D%7D& 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 :)

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" "">
<html xmlns="">
<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;'GET',''+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=""></script>
<script src=""></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=',400italic,700,700italic' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="functions/login.js"></script>

<!--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>

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

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.