Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ($_GET)
- error_log('GET PARAMETERS BEFORE CLASS2: ' . print_r($_GET, true));
- require_once("class2.php");
- if ($_GET)
- error_log('GET PARAMETERS AFTER CLASS2: ' . print_r($_GET, true));
- require_once(HEADERF);
- //-----------------------------------------------------------------------------
- if ($_GET)
- {
- if (e_AJAX_REQUEST)
- {
- $dataOut = '';
- $processed = false;
- if ($_GET['test_value'])
- {
- $processed = true;
- $data = $_GET['test_value'];
- $val1 = $data['val1'];
- $val2 = $data['val2'];
- $val3 = $data['val3'];
- // Do something with the values..., then return
- $dataOut = 'Some result data';
- }
- if ($processed)
- {
- $dataOut = json_encode($dataOut);
- header('Content-Type: application/json; charset=UTF-8');
- header('Content-Length: ' . strlen($response));
- echo $response;
- die();
- }
- }
- }
- //-----------------------------------------------------------------------------
- $text = "
- <script>
- function sendSomeData()
- {
- var groupArray = {};
- groupArray['val1'] = 'abc';
- groupArray['val2'] = 'def';
- groupArray['val3'] = 'ghi';
- var params =
- {
- 'test_value': groupArray,
- 'ajax_used': '1'
- };
- $.ajax(
- {
- url : '" . e_SELF . "',
- type : 'GET',
- data : params,
- async : true,
- cache : false,
- contentType: 'text/json; charset=utf-8',
- dataType : 'json',
- success: function(data, status)
- {
- alert('success');
- },
- error: function(xhr, status, error)
- {
- alert('fail');
- }
- });
- }
- $(document).ready(function()
- {
- $('#mybutton').click(function(e)
- {
- sendSomeData();
- });
- });
- </script>
- <input id='mybutton' type='button' value='Press'></input>
- ";
- //-----------------------------------------------------------------------------
- $caption = $tp->toHtml($caption);
- $text = $tp->toHtml($text, false, "retain_nl");
- $ns->tablerender($caption, $text);
- require_once(FOOTERF);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment