sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Webdialog connect to PHP

    Scheduled Pinned Locked Moved Developers' Forum
    13 Posts 4 Posters 2.0k Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • thomthomT Offline
      thomthom
      last edited by

      You could make an AJAX request.
      http://api.jquery.com/category/ajax/

      Btw, what happens when you use #post_url?

      Thomas Thomassen — SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • K Offline
        krisjaniszakis
        last edited by

        It gives me blank page and doesn't transfer
        data
        array to that page 😞

        I will try to look at AJAX thanks.

        1 Reply Last reply Reply Quote 0
        • thomthomT Offline
          thomthom
          last edited by

          hm.. well, at least AJAX will work. I've used that myself.

          Thomas Thomassen — SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

          1 Reply Last reply Reply Quote 0
          • G Offline
            Gábor
            last edited by

            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.

            1 Reply Last reply Reply Quote 0
            • K Offline
              krisjaniszakis
              last edited by

              Thanks I thought about it too, but could you pleas post small code example ?

              1 Reply Last reply Reply Quote 0
              • G Offline
                Gábor
                last edited by

                @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; ?>
                
                
                1 Reply Last reply Reply Quote 0
                • jiminy-billy-bobJ Offline
                  jiminy-billy-bob
                  last edited by

                  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 😄

                  25% off Skatter for SketchUcation Premium Members

                  1 Reply Last reply Reply Quote 0
                  • jiminy-billy-bobJ Offline
                    jiminy-billy-bob
                    last edited by

                    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.

                    25% off Skatter for SketchUcation Premium Members

                    1 Reply Last reply Reply Quote 0
                    • K Offline
                      krisjaniszakis
                      last edited by

                      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;

                      1 Reply Last reply Reply Quote 0
                      • thomthomT Offline
                        thomthom
                        last edited by

                        That would be limited by the URL scheme. I cannot remember the maximum size...

                        Thomas Thomassen — SketchUp Monkey & Coding addict
                        List of my plugins and link to the CookieWare fund

                        1 Reply Last reply Reply Quote 0
                        • G Offline
                          Gábor
                          last edited by

                          Don't forget to urlencode/urldecode the variable if it contains special characters...

                          1 Reply Last reply Reply Quote 0
                          • jiminy-billy-bobJ Offline
                            jiminy-billy-bob
                            last edited by

                            @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

                            25% off Skatter for SketchUcation Premium Members

                            1 Reply Last reply Reply Quote 0
                            • 1 / 1
                            • First post
                              Last post
                            Buy SketchPlus
                            Buy SUbD
                            Buy WrapR
                            Buy eBook
                            Buy Modelur
                            Buy Vertex Tools
                            Buy SketchCuisine
                            Buy FormFonts

                            Advertisement