Couple questions:
1) I'm trying to have a new random value updated each time a button is pressed. When the button is clicked, a value is generated once... but is not random. So I'm not sure if the function is being called again on click because a new value isn't generated.
2) Can I include the php code within the same file as the jquery when using a server call such as $.get() and call it as a function within that same file?
The reason is, I don't want to have to keep creating new php script files, and would rather throw the code in the same file as the calling jquery.
Meaning...
Instead of $.get("../scripts/NameGenerator2.php",
I do this: $.get("a php function within this same file",
JQuery:
<?php
if ($imgid == 1) {
?>
<button onclick="generate()">Generate</button>
<button id="generateButton">Generate</button>
<script type="text/javascript">
$(document).ready(function() {
$("#generateButton").click(function(e) {
//alert("called");
$.get("../scripts/NameGenerator2.php",
function(returned_data) {
$("#generated").html(returned_data);
}
).error(function(jqXHR, status, error) {
console.log("error in $.get")
});
});
});
</script>
<?php } ?>
<br /><span id="generated"></span><br />
PHP:
<?php
$adj = array("Happy", "Great", "Mandarin", "New", "Golden", "Ming's");
$noun = array("Dragon", "Sea", "Wok", "Fortune", "Rice", "Empire");
$place = array("Garden", "China", "Village", "Palace", "Kitchen", "Mountain");
$x = rand(0, count($adj)-1);
$y = rand(0, count($noun)-1);
$z = rand(0, count($place)-1);
echo '<p>' . $adj[$x] . " " . $noun[$y] . " " . $place[$z] . '</p>';
?>
Any thoughts? Thanks!
Updated: Only error I seem to be getting is "Object Expected" in my "myJquery.js" file, which is not the file I'm working in, and doesn't seem connected.

When I add in document ready to my function, the button onclick() call seems to break.
