jquery ajax get return value
ajax, javascript, jquery
Solution
I think what you want to do is this.
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"><\script>
<script type="text/javascript">
function showGetResult( name )
{
jQuery.ajax({
url: 'http://localhost/index.php',
type: 'get',
dataType: 'text/html',
success:function(data)
{
alert(data);
document.write(data);
}
});
}
showGetResult('test');
</script>
Problem
i want to get the 'printed value' of html pages. i tried below query, but showGetResult() just return 'null value' but my apache server logs printed i accessed index.php when i try this code. (index.php just print helloworld) ``` <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"><\script> <script type="text/javascript"> function showGetResult( name ) { var result = null; jQuery.ajax({ url: 'http://localhost/index.php', type: 'get', dataType: 'text/html', success:function(data) { alert(data); result = data; } }); return result; } document.write(showGetResult('test')); </script> ```