I am having some difficulty with this script: <script type="text/javascript"> function register(){ var uname = "<?=$session['session_key'];?>"; $.ajax({ type: "POST", url: "http://myurl.com/test/submit_data.php", data: "username=" + uname, success: function(html){ $("#response").html(html); } }); } </script> HTML: Then for html: <a href="javascript:register()"><img src="http://myurl.com/themes/images/stp.jpg" class="imglink" border=0/></a> <div id="response"></div> HTML: I just want the div to echo whatever submit_data.php echo's.
stick an alert() or a console.log() in there to check your function is being called. Or add an event handler to it like this: $('a.imglink').click(function(){ register(); }); Code (markup):
Use normal JavaScript, if this ain't working. function register(){ with(x = new XMLHttpRequest()) open("POST", "http://myurl.com/test/submit_data.php", false), setRequestHeader("Content-Type", "application/x-www-form-urlencoded"), send(post); document.getElementById("id_of_div").innerHTML = x.responseText; } Code (markup):