Category Archives: Javascript

Shorthand AJAX examples


$.get("test.php", function(data){
  $('#myFormField').val(data);
});



$.load('myScript.php', function(data) {
    //fill a hidden textbox with your script output and reveal it
    $('#textBox').val(data).show();
)};


AJaX request

Simple AJAX request

 

        $('#loginSubmit').on('click', function(e){
            e.preventDefault();
            checkLogin();
        })
        
        function checkLogin()
        {
             $.ajax({
                url: "ajax/login.php",
                type: "POST",
                data: {
                    username: $("#form_signin #email").val(),
                    password: $("#form_signin #password").val()
                },
                success: function(response)
                {
                    if(response == 'true'){
                        window.location.replace("/saved-route.php");
                    } else {
                        $("#errorMessage").replaceWith('

'+response+'

'); } } }); }