• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Webdialog connect to PHP

Scheduled Pinned Locked Moved Developers' Forum
13 Posts 4 Posters 2.0k Views
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.
  • K Offline
    krisjaniszakis
    last edited by 28 May 2013, 09:08

    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
    • T Offline
      thomthom
      last edited by 28 May 2013, 09:26

      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 28 May 2013, 09:57

        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 28 May 2013, 10:28

          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 28 May 2013, 11:10

            @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
            • J Offline
              jiminy-billy-bob
              last edited by 28 May 2013, 11:12

              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
              • J Offline
                jiminy-billy-bob
                last edited by 28 May 2013, 11:16

                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 28 May 2013, 11:59

                  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
                  • T Offline
                    thomthom
                    last edited by 28 May 2013, 12:10

                    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 28 May 2013, 12:20

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

                      1 Reply Last reply Reply Quote 0
                      • J Offline
                        jiminy-billy-bob
                        last edited by 28 May 2013, 12:55

                        @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
                        1 / 1
                        • First post
                          12/13
                          Last post
                        Buy SketchPlus
                        Buy SUbD
                        Buy WrapR
                        Buy eBook
                        Buy Modelur
                        Buy Vertex Tools
                        Buy SketchCuisine
                        Buy FormFonts

                        Advertisement