Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $config = array();
- $config['url_to_scripts'] = 'https://someserver.com/av/mobile/resources/js';
- error_log('count: '. (count($_POST)). ', name: '.$_POST['name'].', email: '. $_POST['email'].', memory: '.$_POST['memory']);
- if(count($_POST) > 0){
- header('Content-type: text/javascript');
- $json = array(
- 'success' => false,
- 'result' => 0
- );
- if(isset($_POST['name'], $_POST['email'], $_POST['memory'])){
- error_log('I have the post data I am looking for');
- $name = $_POST['name'];
- $email = $_POST['email'];
- $memory = $_POST['memory'];
- $json['success'] = true;
- $json['result'] = $name;
- }
- echo json_encode($json);
- exit;
- }
- ?>
- <html>
- <head>
- <style type="text/css">
- </style>
- <!-- load the css used by the jquery-mobile library -->
- <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" />
- <!-- load the jquery library -->
- <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
- <!-- load the js that binds to various jqm events here, BEFORE loading jqm -->
- <script src="<?php echo $config['url_to_scripts'];?>/sandbox_ajax_form.js"></script>
- <!-- load the jquery-mobile (jqm) library -->
- <script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
- </head>
- <body>
- <!-- all css, script, and page content for this page GO INSIDE THIS DIV
- Caution: any script is executed each time the page is displayed (cached or new)
- so this is not a good place to bind events
- -->
- <div data-role="page" id="formPage" data-theme="b" data-content-theme="b">
- <p>A link to <a href="sandbox_m1.php">sandbox_m1.php</a></p>
- <form id="form" method="POST" data-ajax="false" data-transition="pop" data-direction="reverse">
- <fieldset>
- <label for="name" class="ui-hidden-accessible">Name</label>
- <input type="text" name="name" id="name" value="" class="required" placeholder="Name"/>
- <label for="email" class="ui-hidden-accessible">E-Mail</label>
- <input type="email" name="email" id="email" value="" class="required" placeholder="E-Mail"/>
- <label for="memory" class="ui-hidden-accessible">Memory</label>
- <textarea name="memory" name="memory" id="memory" class="required" placeholder="Your Memory..."></textarea>
- <label for="submit" class="ui-hidden-accessible">Submit</label>
- <input type="submit" name="submit" id="submit" value="SEND">
- </fieldset>
- </form>
- <script>
- console.log('script in the content area of #formPage');
- /*
- Strange Behavior Note:
- js code placed here will get executed:
- -- JUST ONCE if this is the very first page that is loaded and never again when returning to this page
- -- EVERY TIME this page is displayed if this page was NOT the very first page that was loaded
- */
- // .. do stuff here
- </script>
- </div>
- </body>
- </html>
- <?php
- function dump_results($var_2_dump, $label=''){
- if($label){
- echo "Dumping ".$label."<br />\n";
- }
- echo "<pre>";
- var_dump($var_2_dump);
- echo "</pre>\n";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement