[OpenLayers-Users] OpenLayers.Request POST and IE 6/7 issues
Tim Schaub
tschaub at opengeo.org
Tue Oct 28 00:24:16 EDT 2008
Hey-
Ian wrote:
> I am using the print map code from the wiki and opening the printed
> image in a new browser window (for testing I am just opening a Blackle
> page):
>
> new OpenLayers.Request.issue({method:'POST', url:printURL,
> params:{width:size.w, height:size.h, tiles:tiles_json}, callback:
> function(request) {alert(request.status); alert(request.responseText);
> window.open('http://www.blackle.com','_blank');}});
Are you really intending to overload POST (by sending your data as a
query string)?
Try this:
OpenLayers.Request.POST({
url: printURL,
data: OpenLayers.Util.getParameterString({
width: size.w, height: size.h, tiles: tiles_json
}),
callback: function(request) {
alert(request.status);
alert(request.responseText);
}
})
A few things to note:
1) The OpenLayers.Request functions are straight-up functions, not
object constructors. So, no need to use the "new" keyword. Read
http://trac.openlayers.org/wiki/Request for examples of their use.
2) The "params" option to a GET request gives you URI component encoding
of your params property/value pairs in a GET query string. This is not
for use in other request methods.
3) The OpenLayers.Util.getParameterString function takes an object and
serializes property/value pairs using form-encoding (with the exception
of array values). This is typically what you should be sending as the
data in a POST request. I have no idea if your service properly reads
form encoded data from POST - but it should.
4) If the responseText is not html (like maybe pdf, png, or some other
image type), you should not be stuffing it into a new window. When IE
supports the data: scheme, this could work. I should probably read the
wiki page that you reference, you might not be doing this at all.
Anyway, if the above works, then you can do what you want to with the
response.
Tim
>
> All works as expected in Firefox. Internet Explorer 6 throws an "Unknown
> name" error at a line outside of my js file, never alerts the status
> code or responseText, and never opens a new window. Internet Explorer 7
> returns status code 122, empty responseText, and then opens a new
> window, which according to http://www.codebelay.com/blog/?p=194 occurs
> because IE7 is limiting the size of GET strings. The solution is to do a
> POST, which is what I'm doing...
>
> Has anyone else seen this behavior and found a solution?
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
--
Tim Schaub
OpenGeo - http://opengeo.org
Expert service straight from the developers.
More information about the Users
mailing list