44
rated 0 times
[
45]
[
1]
/ answers: 1 / hits: 22383
/ 11 Years ago, tue, september 3, 2013, 12:00:00
I'm trying to send an input value to a php script and have the returned value posted to a div, using ajax, but I can't seem to get this right. Any help/suggestions would be appreciated. Thanks!!
This is what I have by now, but console says: Failed to load resource: the server responded with a status of 404 (Not Found).
test1.php:
<script>
$.ajax({
type: 'POST',
url: 'test2.php',
data: {url: $('#id1').val()},
success: function (data)
{
$(document).ready(function(){$(#content).load(test2.php);});
}
});
</script>
<form name=input>
<input type=text id=id1>
<input type=submit>
</form>
<div id=content></div>
test2.php:
<?php
$string=$_POST['id1'];
require_once('connect.php');
$inf = SELECT * FROM `comments` WHERE date='$string';
$info = mysql_query($inf);
while($info2 = mysql_fetch_object($info)) {echo $info2->username.$info2->date;}
?>
More From » php