I tried now Ajax with mobilefirst to invoke business rules i tried this in my main.js file inside a button click handler:
$.ajax({
type: "POST",
url: "https://brsv2-0cc90e37.ng.bluemix.net/DecisionService/rest/vacationsRuleApp/164.0/vacationsRuleProject/1.0",
async: false,
withCredentials: true,
headers: {Authorization: "Basic " + "credentials"},
data: {
"employeeID": "anything",
"loanAmount": 2320,
"theEmployee": {
"seniority": 3,
"annualSalary": 10517320,
"nbOfExtraVacationDaysBasedOnSeniority": 10517320
},
"creditAmount": 20000,
"__DecisionID__": "string",
"AnnualSalary": 20000
}
}).done(function(response) {
alert("Success");
alert(JSON.stringify(response)); // if you're into that sorta thing
}).fail(function(response) {
alert("Fail");
alert(JSON.stringify(response)); // if you're into that sorta thing
});
then i tried to get the error and i found this from the json.stringify(response):
NetworkError: Failed to execute 'send' on 'XMLHttpRequest':Failed to load 'https://brsv2-0cc90e37.ng.bluemix.net/DesicionService/rest/vacationsRuleApp/164.0/vacationsRuleProject/1.0.
and when i inspectelement on my chrome browser i find this error:
XMLHttpRequest cannot load https://brsv2-0cc90e37.ng.bluemix.net/DecisionService/rest/vacationsRuleApp/164.0/vacationsRuleProject/1.0. No 'Access-Control-Allow-Origin' header is present on the requested resource