SHOW:
|
|
- or go back to the newest paste.
1 | $(document).on('click','#page_login_submit',function(){ | |
2 | var name = $('#page_login_name').val(); | |
3 | if (!name) { alert('Please enter your user name.'); return false; } | |
4 | var pass = $('#page_login_pass').val(); | |
5 | if (!pass) { alert('Please enter your password.'); return false; } | |
6 | try{ | |
7 | $.ajax({ | |
8 | - | url: "http://url/drupal/test/user/login.json", |
8 | + | url: "http://your_url/endpoint/user/login.json", |
9 | type: 'post', | |
10 | data: 'username=' + encodeURIComponent(name) + '&password=' + encodeURIComponent(pass), | |
11 | dataType: 'json', | |
12 | error: function(jqXHR, textStatus, errorThrown) { | |
13 | alert('page_login_submit - failed to login'); | |
14 | alert(JSON.stringify(jqXHR)); | |
15 | alert(JSON.stringify(textStatus)); | |
16 | alert(JSON.stringify(errorThrown)); | |
17 | }, | |
18 | success: function (data) { | |
19 | var drupal_user = data.user; | |
20 | alert ('welcome ' + drupal_user.name); | |
21 | $.mobile.changePage("index.html", "slideup"); | |
22 | }}); | |
23 | ||
24 | ||
25 | // END: drupal services user login | |
26 | return false; | |
27 | } | |
28 | catch(error) { alert("login - " + error)}; | |
29 | }); |