this is the code am executing...
function registration() {
var serverUrl = 'https://api.appery.io/rest/1/db/users';
Code: Select all
var username = document.getElementById('startScreen_username_input').value;
var password = document.getElementById('startScreen_password_input').value;
var firstname = document.getElementById('startScreen_firstname_input').value;
var lastname = document.getElementById('startScreen_lastname_input').value;
alert("Successfully loaded " + username);
var str="{username:"+username+"},{password:"+password+"},{firstname:"+firstname+"},{lastname:"+lastname+"}";
alert("Successfully loaded " + str);
var data=JSON.stringify(str);
alert("Successfully loaded " + data);
$.ajax({
type: "POST",
beforeSend: function(request) {
request.setRequestHeader("X-Appery-Database-Id", 'databaseid');
},
url: serverUrl,
data:data,
processData:false,
contentType: "application/json",
success: function(data) {
console.log("Successfully loaded");
alert("Successfully loaded");
// OPTIONAL, this is the file name under which the image was stored in database....
// localStorage.setItem('db_file_name', data.filename);
},
error: function(xhr) {
console.log("Load error: " + xhr.status + " " + xhr.responseText);
alert("error loaded");
// do something in case of an error...
}
}); }