I have a function called this.create()
this.create = function() {
var validate = this.validate();
if (validate === false) {
return;
} else if (document.getElementById("nameID").value == "") {
alert("Enter an ID");
} else {
this.runMapping();
$.post('http://*************', {
}, function(data) {
var results = $.parseJSON(data);
if (results.status == "fail") {
alert('FAILED');
} else {
ID = (results.data[0].nameID);
alert("SUCCESS");
this.setDate();
}
});
}
}
And another function called this.setDate()
:
this.setDate = function() {
alert("In date");
$.get('http:**********',
function(data) {
var results = $.parseJSON(data);
date = (results.data[0].date);
return;
}
)
}
Now, if I put this.setDate()
on its own button it works fine, but it refuses to run when this.create()
is called, even though alert("SUCCESS")
is alerted in the this.create()
function.
I should add that I am relativity new to JS, so please excuse me if this is an easy mistake I am making. I also note that this.runMapping()
is working fine in this.create()
.