Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).on('click','#page_login_submit',function(){
- var name = $('#page_login_name').val();
- if (!name) { alert('Please enter your user name.'); return false; }
- var pass = $('#page_login_pass').val();
- if (!pass) { alert('Please enter your password.'); return false; }
- try{
- $.ajax({
- url: "http://url/drupal/test/user/login.json",
- type: 'post',
- data: 'username=' + encodeURIComponent(name) + '&password=' + encodeURIComponent(pass),
- dataType: 'json',
- error: function(jqXHR, textStatus, errorThrown) {
- alert('page_login_submit - failed to login');
- alert(JSON.stringify(jqXHR));
- alert(JSON.stringify(textStatus));
- alert(JSON.stringify(errorThrown));
- },
- success: function (data) {
- var drupal_user = data.user;
- alert ('welcome ' + drupal_user.name);
- $.mobile.changePage("index.html", "slideup");
- }});
- // END: drupal services user login
- return false;
- }
- catch(error) { alert("login - " + error)};
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement