2
\$\begingroup\$
    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.

\$\endgroup\$
2
\$\begingroup\$

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>
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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