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 page
I 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
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register LoginAdvertisement