<script type="text/javascript" src="http://server/arcgis_js_api/library/3.1/jsapi/"></script> <script language="javascript"> function geoprocessing(){ // returns an array of well-known text values; var polyArray = retrieveValues(); var gpurl = "http://server/ArcGIS/rest/services/ls_geoproc/GPServer/Landscan"; gp = new esri.tasks.Geoprocessor(gpurl); var params = { "WKT":polyArray }; gp.submitJob(params, completeCallback, statusCallback); } function statusCallback(jobInfo){ console.log(jobInfo.jobStatus); } function completeCallback(jobInfo){ console.log(jobInfo.jobID); console.log(jobinfo.jobStatus); }
LOG: esriJobSubmitted LOG: esriJobExecuting LOG: esriJobSucceeded LOG: undefined [object Error] [object Error]
Solved! Go to Solution.
function geoprocessing(){ var polyArray = retrieveValues(); var gpurl = "http://server/ArcGIS/rest/services/ls_geoproc/GPServer/Landscan"; gp = new esri.tasks.Geoprocessor(gpurl); var params = { "WKT":polyArray }; gp.submitJob(params, completeCallback, statusCallback, errorCallback); } function statusCallback(jobInfo){ // try to print the jobID here as well; console.log(jobInfo.jobID); console.log(jobInfo.jobStatus); } function completeCallback(jobInfo){ console.log(jobInfo.jobID); console.log(jobinfo.jobStatus); } function errorCallback(error){ console.log(error.name); console.log(error.message); }
LOG: undefined LOG: esriJobSubmitted LOG: undefined LOG: esriJobExecuting LOG: undefined LOG: esriJobSucceeded LOG: undefined [object Error] [object Error]
According to the documentation the property is jobId not jobID - JS is case-sensitive so this explains the undefined on some of those lines 🙂
D'oh! It was staring right at me and I managed to overlook it
I have attached the network log resulting from the job submittal in case that offers any insights.
function completeCallback(jobInfo){ debugger; //Poor man's breakpoint ;-) }
I figured out the issue. In the completeCallback function I had "jobinfo" instead of "jobInfo" which was generating the error. I thought I had seen "jobinfo" in some samples, and thus had tried testing first one and then the other capitalization but evidently missed this one when changing around. Thanks Rich for your help, much appreciated!
function completeCallback(jobInfo){
console.log(jobInfo.jobID);
console.log(jobinfo.jobStatus);
}