I have a WordPress page that should load some code from the server using jQuerys load method:
<div id="mydiv"></div>
<script>
jQuery("#mydiv").load("http://localhost/testserver/wp-content/plugins/myplugin/scripts/view/test.php?x=1&y=2&z=3");
</script>
My test.php script is:
<?php error_log(var_export($_GET,true)); ?>
But I am unable to get the parameters x, y, z correctly in the test.php script: The output in the error log shows:
'x' => '1',
'amp;y' => '2',
'amp;z' => '3',
(If I use x=1&y=2&z=3 in the url string, I just get ‘x’ => ‘1’, in the error log).
Am I doing something wrong or could this be a WordPress or jQuery bug?
Use encodeURIComponent();
Example
Alternatively use .get()
http://api.jquery.com/load/
Example: pass arrays of data to the server.