www.webdeveloper.com
Results 1 to 3 of 3

Thread: Get php variables from server

  1. #1
    Join Date
    Aug 2014
    Posts
    10

    Get php variables from server

    Is there a way to load variables from a php site while inside a mobile jquery app?

  2. #2
    Join Date
    Mar 2012
    Posts
    1,742
    That depends on what you mean by the question. If you mean "can PHP scripts be written to pass the contents of variables to the client", the answer is yes. If you mean "can a client (any client) directly access the PHP variables on the server" the answer is: of course not. What would lead you to ask such a question???

  3. #3
    Join Date
    Apr 2014
    Posts
    31
    ClientSide HTML
    <html>
    <head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    </head>
    <script>
    $.ajax({
    url: "http://5.175.191.73/test.php",
    dataType: "json", //the return type data is jsonn
    success: function(data){ // <--- (data) is in json format
    alert(data.test1);
    //parse the json data
    }
    });
    </script>
    </html>

    ServerSide PHP
    <?php

    $test = array();
    $test['test1'] = '1';
    $test['test2'] = '2';
    $test['test3'] = '3';

    echo json_encode($test);

    ?>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles