Webdialog connect to PHP
-
You could make an AJAX request.
http://api.jquery.com/category/ajax/Btw, what happens when you use #post_url?
-
It gives me blank page and doesn't transfer
data
array to that pageI will try to look at AJAX thanks.
-
hm.. well, at least AJAX will work. I've used that myself.
-
There is an other possible hack - however more complicated - to use GET variables instead of POST:
- You open index.php in your webdialog.
- index.php contains the Javascript to get the Ruby variables
- You make a Javascript redirect with the variables appended to the URL as GET variables.
- You have the GET variables available at the .php side.
Not a usual solution but works.
-
Thanks I thought about it too, but could you pleas post small code example ?
-
@krisjaniszakis said:
...could you pleas post small code example ?
A possible exampele for myfile.php:
<?php if(isset($_GET['v'])) ; ?> The variable; <?php echo $_GET['v']; ?> <?php else ; ?> <html> <head> <script type="text/javascipt"> var v=[ your function to get the ruby variables ]; function myredirect() { window.location='http://myserver.com/myfile.php?v=' + v; } window.onload=myredirect(); </sript> </head> <body> </body> </html> <?php endif; ?>
-
Something like
First page, js :
window.location.href = "http://www.domain.com/page.php?param=foo"
Second page, php :
<?php echo $_GET['param']; ?>
(Returns "foo")
EDIT : Well, too slow
-
Gábor's exemple is similar to the behavior of an HTTP redirect (window.location.replace("");)
While mine is similar to the behavior of clicking on a link (window.location.href = "";)Depends on what you want to do.
-
Thanks Gábor and jiminy-billy-bob I combined both scripts and now understand how to do it
Does some one know how big(length) array ("v") I can send through ?
window.location='http://myserver.com/myfile.php?v=' + v;
-
That would be limited by the URL scheme. I cannot remember the maximum size...
-
Don't forget to urlencode/urldecode the variable if it contains special characters...
-
@krisjaniszakis said:
Does some one know how big(length) array ("v") I can send through ?
http://stackoverflow.com/a/7725515
But big data like this you should go with POST instead of GET
Advertisement