Unidentified
Living the Developer Life...
- Jun 19, 2012
- 144
- 20
I am new to using ajax and somink is wrong because it aint posting.
Test.php
../ajax/post.php?ref?ref=profile&goto=home&ex=newpost
Test.php
Code:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/
libs/jquery/1.3.0/jquery.min.js">
</script>
<script type="text/javascript" >
$(function() {
$("#ntb").click(function() {
var nt = $("#nt").val();
var data=$('#nt').serialize();
if(nt=='')
{
$('.success').fadeOut(200).hide();
$('.error').fadeOut(200).show();
}
else
{
$.ajax({
type: "POST",
url: "../ajax/post.php?ref=profile&goto=home&ex=newpost",
data: dataString,
success: function(){
$('.success').fadeIn(200).show();
$('.error').fadeOut(200).hide();
}
});
}
return false;
});
});
</script>
<form method="post" name="form">
<input id="nt" name="nt" type="text" />
<input type="submit" style="display:block;" name='ntb' id='ntb' class="Buttonchat" value="Post" />
</form>
<div>
<span class="error" style="display:none"> Please Enter Valid Data</span>
<span class="success" style="display:none"> Registration Successfully</span>
</div></form>
../ajax/post.php?ref?ref=profile&goto=home&ex=newpost
PHP:
<?php
include '../core/init.php';
if(isset($_GET['ex'])){
if($_GET['ex'] == 'newpost' && isset($_POST['nt']) && isset($_POST['ntb'])){
mysql_query("INSERT INTO `post` (`myid`, `text`) VALUES ('".$_SESSION['id']."', '".mysql_real_escape_string($_POST['nt'])."')");
}
}
?>