i have tried implementing what you said but i cannot get it to work.
below is my ajax code so far
display.html
Code:
<script type="text/javascript">
$(document).ready(function() {
var id = getUrlVars()["id"];
$.ajax({ type: "POST",
url:'http://localhost/services/pass_count101.php',
data:"id="+id+"&message="+message,
success:function(data){
$('#result_count').html(data);
} })
});
</script>
insert.html
Code:
<script type="text/javascript">
$(document).ready(function() {
$("#msg").hide();
$("#btn").click(function(){
$("#response").slideUp("slow");
//alert("hi");
var jsonData = {};
var formData = $("#myform").serializeArray();
$.each(formData, function() {
if (jsonData[this.name]) {
if (!jsonData[this.name].push) {
jsonData[this.name] = [jsonData[this.name]];
}
jsonData[this.name].push(this.value || '');
} else {
jsonData[this.name] = this.value || '';
}
});
console.log(jsonData);
$.ajax(
{
url : "http://localhost/services/insert.php",
type: "POST",
data : jsonData,
success:function(data, textStatus, jqXHR)
{
$("#response").text("");
$("#response").append(data);
$("#response").slideDown("slow");
}
});
$("#msg").show("slow");
});
});
</script>
helps will be appreciated. thanks
Bookmarks