Guest User

Untitled

a guest
Feb 24th, 2010
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.06 KB | None | 0 0
  1. # index.html
  2.  
  3. <html>
  4. <head>
  5.     <meta http-equiv='content-type' content='text/html;charset=utf-8' />
  6.     <script language="JavaScript" type="text/javascript" src="prototype.js"></script>
  7.     <script type="text/javascript">
  8.         // ... ajax request ...
  9.         function WTF(value_A, value_B)
  10.         {
  11.             new Ajax.Request("/request.php", {
  12.                 method: 'post',
  13.                 parameters: {
  14.                     wtf_var_A: value_A,
  15.                     wtf_var_B: 'много букоф!',
  16.                     wtf_var_C: value_B,
  17.                 },
  18.                 asynchronous: true,
  19.                 onComplete: function(json) {
  20.                    
  21.                     rst = eval('(' + json.responseText + ')');
  22.                    
  23.                     alert("wtf_var_A:" + rst.wtf_var_A + ", wtf_var_B:" + rst.wtf_var_B + ", wtf_var_C:" + rst.wtf_var_C);
  24.                 }
  25.             });
  26.         }
  27.         // ... ajax request ...
  28.     </script>
  29. </head>
  30. <body>
  31. <a onclick="WTF(111, 222); return;">тынц</a>
  32. <div id='request'></div>
  33. </body>
  34. </html>
  35.  
  36. # request.php
  37.  
  38. <?php
  39. header("Content-type: text/html; charset=utf-8");
  40.  
  41. $array = array();
  42.  
  43. foreach ($_POST as $key => $value) $array[] = '"'.$key.'": "'.$value.'"';
  44.  
  45. echo '{'.join(", ", $array).'}';
  46. ?>
Advertisement
Add Comment
Please, Sign In to add comment