Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- headers etc. omitted -->
- <script>
- function callPHP(params) {
- var httpc = new XMLHttpRequest(); // simplified for clarity
- var url = "get_data.php";
- httpc.open("POST", url, true); // sending as POST
- httpc.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- httpc.setRequestHeader("Content-Length", params.length); // POST request MUST have a Content-Length header (as per HTTP/1.1)
- httpc.onreadystatechange = function() { //Call a function when the state changes.
- if(httpc.readyState == 4 && httpc.status == 200) { // complete and no errors
- alert(httpc.responseText); // some processing here, or whatever you want to do with the response
- }
- }
- httpc.send(params);
- }
- </script>
- <a href="#" onclick="callPHP('lorem=ipsum&foo=bar')">call PHP script</a>
- <!-- rest of document omitted -->
- <script language="javascript" type="text/javascript">
- function _vals(target, value){
- form1.all("target").value=target;
- form1.all("value").value=value;
- form1.submit();
- }
- </script>
- <a onclick="_vals('name', 'val')" href="#">My Link</a>
- $val = $_POST['value'];
- <script>
- var php_value = '<?php echo $php_variable; ?>';
- var infobar_active = $.cookie('php_value');
- var infobar_alert = any_process(infobar_active);
- //set a cookie to readit via php
- $.cookie('infobar_alerta', infobar_alerta );
- </script>
- <?php
- var js_value = code to read a cookie
- ?>
Add Comment
Please, Sign In to add comment