Created
March 17, 2014 13:22
-
-
Save canoedf/9599070 to your computer and use it in GitHub Desktop.
Calling a 2nd page with php/javascript from php/javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
post_to_url('/grid3/ack.php',{Tm:'%Tm%',Host:'%Host%',Monitor:'%Monitor%',Status:'%Status%',Event:'%Event%'}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
function post_to_url(path, params, method) { | |
method = method || "post"; // Set method to post by default if not specified. | |
var form = document.createElement("form"); | |
form.setAttribute("method", method); | |
form.setAttribute("action", path); | |
for(var key in params) { | |
if(params.hasOwnProperty(key)) { | |
var hiddenField = document.createElement("input"); | |
hiddenField.setAttribute("type", "hidden"); | |
hiddenField.setAttribute("name", key); | |
hiddenField.setAttribute("value", params[key]); | |
form.appendChild(hiddenField); | |
} | |
} | |
document.body.appendChild(form); | |
form.submit(); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment