[OpenLayers-Users] How to force browser to download a file with a OpenLayers request response
Robert Sanson
Robert.Sanson at asurequality.com
Thu Jul 31 13:57:13 PDT 2014
One option would be to get your Python script to Zip the file and place it somewhere on your Web server, then return some HTML (instead of application/json) with a link to the file.
Regards,
Robert
>>> VictoriaH <bhudspeth at edac.unm.edu> 1/08/2014 8:46 a.m. >>>
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.
_______________________________________________
Users mailing list
Users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users
This email and any attachments are confidential and intended solely for the addressee(s). If you are not the intended recipient, please notify us immediately and then delete this email from your system.
This message has been scanned for Malware and Viruses by Websense Hosted Security.
www.websense.com
More information about the Users
mailing list