I am trying to learn a bit of AJAX but am struggling with getting the output from the php script.
Here is the code I am using at the moment:
<form>
<input type="text" id="url" name="url" value="" onkeydown="if (event.keyCode == 13 || event.which == 13) {go($('#url').val());} "/><input type="submit" id="submit" name="submit" value="SHORTEN" onclick="go($('#url').val());"/>
</form>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script src="js/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
function go(url){
$.post('url.php', {url: url},
function(data){
$("#result").html(data).stop();
});
alert(url);
};
</script>
currently the url.php script is just echoing out random text for testing purposes.
When I run the go() function with just the alert in it works, but something seems to be wrong with the $.post() function as it isn't getting the echoed string form url.php and no alert box opens when enter or the submit button is clicked.
Thanks
P.S
Heres an example of what im trying to do when you put something in the text field and submit the area underneath is not populated with the output form url.php - chrismepham.co.uk
edit - I am using google chrome