[OpenLayers-Users] OpenLayers.Request POST and IE 6/7 issues

Tim Schaub tschaub at opengeo.org
Wed Oct 29 15:06:35 EDT 2008


Ah, the key is at the bottom (content type):

OpenLayers.Request.POST({
     url: printURL,
     data: OpenLayers.Util.getParameterString(
         {width:size.w, height:size.h}
     ),
     headers: {
         "Content-Type": "application/x-www-form-urlencoded"
     },
     callback: function(request) {
         alert(request.responseText);
     }
});

Tim

Ian wrote:
> 
>     $_REQUEST will contain form-encoded parameters (sent as data in a POST).
> 
> 
> Right, so using your getParameterString example:
> 
> OpenLayers.Request.POST({url: printURL, data: 
> OpenLayers.Util.getParameterString({width:size.w, height:size.h}), 
> callback: function(request) 
> {alert(request.status);alert(request.responseText);}});
> 
> should form encode width and height and it should be in the $_POST array 
> correct? But it isn't. My PHP script is run, Firebug says 
> 'width=500&height=500' is posted, but $_REQUEST, $_POST, and $_GET are 
> all empty.
> 
> I tested the $_POST array outside of OL with:
> 
> <?php
>   if( $_POST["name"] || $_POST["age"] )
>   {
>      echo "Welcome ". $_POST['name']. "<br />";
>      echo "You are ". $_POST['age']. " years old.";
>      exit();
>   }
> ?>
> <html>
> <body>
>   <form action="<?php $_PHP_SELF ?>" method="POST">
> 
>   Name: <input type="text" name="name" />
>   Age: <input type="text" name="age" />
> 
>   <input type="submit" />
>   </form>
> </body>
> 
> and this worked correctly so my PHP installation is fine. I also tried 
> using text/plain headers to no avail. OpenLayers.Request.POST data still 
> is not showing up in PHP's $_REQUEST and $_POST arrays.
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> 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