eval function not working in ajax post
<p>So I am using ajax to post a serialised form to a php script and then on success alert the returned data.
My code works fine on my local environment, but uploaded, the eval() function mucks everything up.</p>

<p>here is my code:</p>

<pre><code>function post_that_shit(formIdToSerialize, postUrl) {
    var serializedData = $("#"+formIdToSerialize).serialize();
    var post_url = postUrl+".php";
    //alert(serializedData + "\n" + post_url);


    $.ajax({
        url: post_url,
        type: "POST",
        data: serializedData,
        success: function(data){
            data = eval('('+data+')' );
            console.log(data.msg);

            if(data.reload == 'yes'){
                window.location.reload();
            }
            if(data.relocate != 'no'){
                window.location.href = data.relocate;
                //alert(data.relocate);
            }
            if(data.msg != 'no'){
                $(".message").html(data.msg);
                //alert(data.msg);
            }

            //alert('relocate: '+data.relocate);
        }
    });


}
</code></pre>

<p>So it is pretty simple.
The php echo out a json encoded array like so:</p>

<pre><code> echo json_encode(array('msg' =&gt; $errors, 'relocate' =&gt; 'no'));
</code></pre>

<p>And depending on what is echoed, the msg is displayed or the user relocated.</p>

<p>Why do I get the error of SyntaxError: Unexpected token ')' when I use the code online?
Locally it works just fine :(</p>

<p>Thanx for your help</p>

<p>Chris</p>