[OpenLayers-Users] How to force browser to download a file with a OpenLayers request response

VictoriaH bhudspeth at edac.unm.edu
Thu Jul 31 13:46:36 PDT 2014


Hello,

I have OpenLayers request that calls a python function that returns a
GeoJSON formatted text. I can display the text contents in an alert box, but
would like to instead force the browser to offer the text as a GeoJSON file
to be downloaded. I would appreciate any help that anyone can offer on how
to do this...

My python script successfully returns a  "Content-Type: application/json\n"
text to the browser, and my request and response code look like this so far:

		var PM_request = OpenLayers.Request.GET({
		    url:'scripts/geoTiff2GeoJSON_edited.py',
		    callback:processData,
		    params:coords
		    //headers:{"Content-Type": "application/json\n"}
		});
		
		function processData(PM_request) {
		    var PMjson = new
OpenLayers.Format.JSON().read(PM_request.responseText);
		    //console.log(PMjson);
		    alert("Result is:" + PM_request.responseText);
		} 


I would like to add functionality to the processData function above that
opens a download window of some sort where once can acquire the GeoJSON
file...

Thank you,

VickH



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/How-to-force-browser-to-download-a-file-with-a-OpenLayers-request-response-tp5154502.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list