- Posts: 17
- Thank you received: 0
<form>
<label for="text-basic" class="ui-hidden-accessible">User Name:</label>
<input type="text" name="username" placeholder="User Name" id="login-username" value="">
<label for="password" class="ui-hidden-accessible">Password:</label>
<input type="password" name="password" id="login-password" placeholder="Password" value="" autocomplete="off">
<div class="ui-field-contain">
<button type="submit" id="submit-6" class="ui-shadow ui-btn ui-corner-all ui-mini">Login</button>
</div>
</form>
<script>
$("#submit-6").click(function(e) {
e.preventDefault();
var credentials = {
username: $('#login-username').val(),
password: $('#login-password').val()
};
jQuery.support.cors = true;
$.ajax({
type: "POST",
url: "http://mywebsite.com/request-end-point/post/user/login",
data: JSON.stringify(credentials),
crossDomain: true,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data) {
// alert(data);
if (data.success === true) {
$.mobile.changePage($('#home'));
} else {
alert(data);
}
},
error: function(errMsg) {
alert(errMsg);
}
});
});
</script>
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
xhrFields
Type: PlainObject
An object of fieldName-fieldValue pairs to set on the native XHR object. For example, you can use it to set withCredentials to true for cross-domain requests if needed.
$.ajax({
url: a_cross_domain_url,
xhrFields: {
withCredentials: true
}
});
Please Log in or Create an account to join the conversation.
Cookies.set('session_id', '18293840187');
$.ajax({
url: a_cross_domain_url,
xhrFields: {
withCredentials: true
}
});
if ( Cookies.get('session_id' ) ) { //if cookie isset
$.mobile.changePage($('#home'));
}else{
$.mobile.changePage($('#page-login'));
}
Please Log in or Create an account to join the conversation.