var url = "url to backend";
console.log("after the url has been defined. in create new job");
var createdJob = esriRequest({
'url' : url,
'query' : {
user: jobSettings.user,
jobtypeid: jobSettings.jobtypeid,
id : jobSettings.id,
name : jobSettings.name,
startdate : jobSettings.startdate,
duedate : jobSettings.duedate,
priority: jobSettings.priority,
parentjobid : jobSettings.parentjobid,
dataworkspaceid : jobSettings.dataworkspaceid,
parentversion : jobSettings.parentversion,
description : jobSettings.description,
ownedby : jobSettings.ownedby,
assignedtype : jobSettings.assignedtype,
assignedto : jobSettings.assignedto,
aoi : jobSettings.aoi,
poi : jobSettings.poi,
numjobs : jobSettings.numjobs,
autocommitworkflow : jobSettings.autocommitworkflow,
autoexecute : jobSettings.autoexecute,
f : 'json'
},
'callbackParamName' : 'callback',
'usePost' : true,
'handleAs' : 'json',
'responseType' : 'json'
}).then(function(response){
console.log("The response is: ", response);
});
console.log("End of createNewJob()");
The code will log "End of createNewJob()" to the console and then give me the error I talked about earlier:
init.js:89 SyntaxError: Unexpected token <
at Object.b.fromJson (init.js:131)
at Object.json (init.js:84)
at r (init.js:88)
at c (init.js:103)
at d (init.js:103)
at b.Deferred.resolve.callback (init.js:105)
at init.js:92
at l (init.js:107)
at t (init.js:107)
at d.resolve (init.js:109)
So when I hit the "Create Job" button, it will go through the whole createNewJob() function and then give me this error in the end but when I take away my esriRequest code, I do not get that error at all. So I am sure it has something to do with this piece of code. I would like to at least see what is being returned so I can see how I would need to modify the code in case the JSON being returned in not being recognized as a JSON. But I can't figure out how I would do that? I have tried adding the following to the code:
createdJob.then(
function(data){
console.log("Success: ", data)
},
function(error){
console.log("Error!!");
}
);
When I run the application with this code, it will log "End of createNewJob()" first to the console and then the error will show up in red and then "Error!!" will be logged??