[OpenLayers-Users] Need Help with OpenLayers.Request
Bill Thoen
bthoen at gisnet.com
Sun Jan 11 15:10:13 EST 2009
No, changing the header doesn't fix it.
Arnd Wippermann wrote:
> I would think, your Content-Type is wrong
>
> http://faq.openlayers.org/ajax/how-do-i-post-form-encoded-data/
>
> Arnd Wippermann
>
> -----Ursprüngliche Nachricht-----
> Von: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im
> Auftrag von Bill Thoen
> Gesendet: Sonntag, 11. Januar 2009 20:48
> An: users at openlayers.org
> Betreff: [OpenLayers-Users] Need Help with OpenLayers.Request
>
> Can somebody explain to me how to pass data to my server side program using
> OpenLayers.Request? The following example seems to work, only there are no
> variables in the $_POST array. My handler prints only:
>
> result is $_POST variables
>
> But apparently the array is empty. What am I missing here?
>
> Here's some sample code that illustrates the problem:
>
> <!-- test_ajax.html -->
> <html>
> <head>
> <title>AJAX Test</title>
> <script src="http://openlayers.org/api/OpenLayers.js"
> type="text/javascript"></script>
> <script type="text/javascript">
>
> function init() {
> var XHR = OpenLayers.Request.POST ({
> url: "test_ajax.php",
> data: "my data",
> params: {var1: 'value 1', var2 : 'value 2'},
> headers: { "Content-Type": "text/plain" },
> callback: myhandler
> });
> }
>
> function myhandler(XHR) {
> alert("result is " + XHR.responseText);
> }
>
> </script>
> </head>
> <body onload="init();">
> <h1>AJAX Test</h1>
> </body>
> </html>
>
>
> // ---------------------
> // test_ajax.php
>
> <?php
>
> echo "\$_POST variables \n";
>
> foreach($_POST as $key => $value){
> echo $key.": ".$value;
> }
> ?>
>
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
>
More information about the Users
mailing list