I am working on a demo showing the error handling in promises using rsvp.js. Everything seemed fine, till I used the CDN url for rsvp.js in a tag. Now since I have require.js for module loading in my application, I tried loading the rsvp.js module via require js syntax. In the Chrome network tab, I see the rsvp.js module getting loaded properly as well, but I get the below error in console,
Uncaught ReferenceError: RSVP is not defined.
require(["bootstrap","js/rsvp"], function(bootstrap,rsvp) {
$(document).ready(function () {
function getEmployeeDetails() {
var radioValue1 = $("input[name='option1']:checked").val();
var requrl;
if (radioValue1 == "fail") {
requrl = "../../../testservice/getEmployeeIdss";
} else {
requrl = "../../../testservice/getEmployeeId";
}
return new RSVP.Promise(function (resolve, reject) {
$.ajax({
url: requrl,
success: function (response) {
try {
$('#successBoard').append("<b> <i> Ajax Call 1 Succeeded! </i> </b><br/>" + "Employee ID:" + response.stuId + "<br/>");
resolve(response.stuId);
} catch (e) {
reject(e);
}
},
error: function (xhr, ajaxOptions, thrownError) {
console.log('Ajax 1 failed : Rejecting Promise 1');
$('#errorBoard').append("<b> <i> Ajax 1 failed : Rejecting Promise 1</i> </b><br/>");
reject(thrownError);
}
});
});
}