I have this part of ajax code on my windows8
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js "></script>
<script>
$(document).ready(function(){
$('#next_Button').click(function(){
var text = document.getElementById("textbox");
var query = text.value;
$('#response').html("<b>Loading response...</b>");
$.ajax({
type: 'POST',
url: 'http://192.168.92.131/search2/info.php',
data: { query : query }
})
.done(function(data){
$('#response').html(data);
alert("sent query");
})
.fail(function() {
alert( "Posting failed." );
});
return false;
});
});
</script>
and php code on my virtual Ubuntu machine
echo $_POST['query'];
IP address is correct and it's always fixed. But ajax always says 'posting failed'. when I put html code on server and just set url :'search2/info.php' it works. but when it's remote server with http:// ipaddress / search2 / phpname it doesn't work. By the way my php code is in var/www/html/search2 hosted on apache. Is this problem from ajax ? even when I click on this complete url it shows server page! but ajax can't use this direct url to .php !