Arsh,
Sure here is a sample. You will have to log into your AGOL account to use this service though.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Query Point Eelvation</title>
<link rel="stylesheet" href="https://js.arcgis.com/3.28/dijit/themes/claro/claro.css" />
<link rel="stylesheet" href="https://js.arcgis.com/3.28/esri/css/esri.css">
<style>
html, body, #map {
height: 100%; width: 100%; margin: 0; padding: 0;
}
#info {
bottom: 20px;
color: #444;
height: auto;
font-family: arial;
left: 20px;
margin: 5px;
padding: 10px;
position: absolute;
text-align: left;
width: 200px;
z-index: 40;
}
</style>
<script src="https://js.arcgis.com/3.28/"></script>
<script>
var map, gp;
require([
"esri/map", "esri/symbols/SimpleMarkerSymbol",
"esri/graphic", "esri/layers/GraphicsLayer",
"esri/Color", "esri/tasks/Geoprocessor",
"esri/tasks/FeatureSet", "dojo/dom",
"dojo/domReady!"
], function(
Map, SimpleMarkerSymbol,
Graphic, GraphicsLayer,
Color, Geoprocessor,
FeatureSet, dom
) {
map = new Map("map", {
basemap: "streets",
center: [-120.741, 56.39],
slider: false,
zoom: 6
});
gp = new Geoprocessor("http://elevation.arcgis.com/arcgis/rest/services/Tools/Elevation/GPServer/SummarizeElevation");
gp.setOutSpatialReference({
wkid: 102100
});
var symbol = new SimpleMarkerSymbol("circle", 14, null, new Color([0, 0, 255, 0.65]));
var gl = new GraphicsLayer({ id: "pointelev" });
map.addLayer(gl);
map.on("click", function(e) {
gl.clear();
var graphic = new Graphic(e.mapPoint, symbol);
gl.add(graphic);
var features = [];
features.push(graphic);
var featureSet = new FeatureSet();
featureSet.features = features;
var params = {
"InputFeatures": featureSet,
"DEMResolution": "FINEST"
};
gp.submitJob(params, completeCallback, statusCallback);
dom.byId("info").innerHTML = "Processing Request";
function completeCallback(jobInfo) {
gp.getResultData(jobInfo.jobId, "OutputSummary", showElevation)
}
function statusCallback(jobInfo){
if(dom.byId("info").innerHTML === "Processing Request..."){
dom.byId("info").innerHTML = "Processing Request";
}else{
dom.byId("info").innerHTML += ".";
}
}
function showElevation(results){
dom.byId("info").innerHTML = "The clicked points elevation is: " + results.value.features[0].attributes.MeanElevation;
}
});
});
</script>
</head>
<body class="claro">
<div id="map"></div>
<div id="info" class="esriSimpleSlider">
Click on map to execute Elevation GP Task.
</div>
</body>
</html>
Don't forget to mark this question as answered by clicking on the "Mark Correct" link on the reply that answered your question.