Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
    function reg(email, pass){
            $.ajax({
                url: "uman.php",
                type: "post",
                data:{email: email, password: pass},
                success: function(reply){
                if (reply == "success"){
                    $("#signinup").hide();
                    $("#donesucc").css("display","block");
                    console.log(reply);
                    }
                    if (reply == "duplicate"){
                        $("#signinup").hide();
                        $("#donedupe").css("display","block");
                    }
                }
            })
        }

Anything I should change? The PHP just echos the status of the query and Javascript takes that value and outputs the results through HTML.

share|improve this question

What do you think about this?

var Request = {
    version: 1.0, //not needed but i like versioning things
    xproxy: function(type, url, data, callback, timeout, headers, contentType) 
    {
        if (!timeout || timeout <= 0) { timeout = 15000; }
        $.ajax(
        {
            url: url,
            type: type,
            data: data,
            timeout: timeout,
            contentType: contentType,
            success:function(data) 
            {
                if (callback != undefined) { callback(data); }
            },
            error:function(data) 
            {
                if (callback != undefined) { callback(data); }
            }, 
            beforeSend: function(xhr)
            {
                //headers is a list with two items
                if(headers)
                {
                    xhr.setRequestHeader('secret-key', headers[0]);
                    xhr.setRequestHeader('api-key', headers[1]);
                }
            }
        });
    }
};

<script type="text/javascript">
var contentType = "applicaiton/json";
var url = "http://api.lastfm.com/get/data/";
var timeout = 1000*5; //five seconds
var requestType = "POST"; //GET, POST, DELETE, PUT

var header = [];
header.push("unique-guid");
header.push("23903820983");

var data = "{\"username\":\"james\"}"; //you should really deserialize this w/ a function
function callback(data)
{
   //do logic here
}
Request.xproxy(requestType, url, data, callback, timeout, header, contentType);
</script>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.