T.oby
Forum Replies Created
-
Forum: Hacks
In reply to: use jquery post onsubmit functionSorry I also tried the immediate form of the wrapper, i.e.:
(function($) { $.post("/test6.php", {"arg1": "1", "arg2": "2"}, function(response) { alert('Got this from the server: ' + response); }); })(jQuery);which did not show the alert box.
Thanks for any help.
Toby
Forum: Hacks
In reply to: use jquery post onsubmit functionThanks, I tried using jQuery.post():
<script> function Do () { $jQuery.post("/test6.php", {"arg1": "1", "arg2": "2"}, function(response) { alert('Got this from the server: ' + response); }); } </script> <form name="Form1" action="" method="post" onsubmit="return Do()"> <input type="submit" value="Send"> </form>which unfortunately also did not work. How would the code for the immediate form of the wrapper look like?
Thanks,
Toby
Forum: Hacks
In reply to: use jquery append functionA slimmer version of the code above:
$("#table1 tbody").append("<tr><td>data1</td></tr>");works in a jsfiddle example. However not in WordPress.
Thanks for any help
Forum: Hacks
In reply to: use jquery get functionIt seems WordPress loads by default the jquery library. But WordPress works in noConflict() mode where the $ operator is not available. Therefore I wrapped my code as suggested in http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_wrappers.
<script> jQuery(document).ready(function($) { $.get('http://portal.3yd.de/wp-content/uploads/2014/04/guggenheim2.jpg').done( function() { alert("image exists"); }).fail(function() { alert("image does not exist"); }); }); </script>However funnily the code only works with images on my website not the w3schools website.
Forum: Plugins
In reply to: [Exec-PHP] page redirects to index.php and gives a 404 with submit buttonAaaah! 🙂 – WordPress has reserved the word “name” which I used as variable name! Solved 🙂
Forum: Plugins
In reply to: [Exec-PHP] page redirects to index.php and gives a 404 with submit buttonI seems that the action attribute in WordPress is even not required because it redirects by default to the same page. Even the minimal example
<form method="post"> Name: <input type="text" name="name"><br> <input type="submit" name="submit" value="Submit"> </form>gives a 404 when the form has a value and the button is clicked. Is this the way to do a post in WordPress?
Any help is highly appreciated.
Forum: Plugins
In reply to: [Exec-PHP] page redirects to index.php and gives a 404 with submit buttonThe issue seems to be the action in the submit button which was
<?php echo $_SERVER["PHP_SELF"];?>and I changed it to
<?php echo esc_attr($_SERVER['REQUEST_URI']);?>With this I can click on the button and the page is reloaded. However if any values in the text inputs are set I again get a 404 without redirecting to index.php but to the same url again.
My complete slimed down w3c example is:
<?php if ($_SERVER["REQUEST_METHOD"] == "POST") { $name = $_POST["name"]; } ?> <form method="post" action="<?php echo esc_attr($_SERVER['REQUEST_URI']);?>"> Name: <input type="text" name="name" value="<?php echo $name;?>"><br> <input type="submit" name="submit" value="Submit"> </form> <?php echo $name ?>Thanks for any help.
Forum: Plugins
In reply to: [Exec-PHP] page redirects to index.php and gives a 404 with submit buttonSorry forgot to post the w3c schools link with the code: http://www.w3schools.com/Php/showphp.asp?filename=demo_form_validation_complete
Forum: Plugins
In reply to: [Multisite Language Switcher] switch between languages of pagesThanks a million!