Welcome Guest, Not a member yet? Register   Sign In
ajax jquery post not working
#1

[eluser]Unknown[/eluser]
hi all, im a beginner in CI n this forum too, i try to use ajax to send my data to DB, but not working, i've tried to solve it, but it's still the same,

this my simple form:
Code:
<table id="formIn">
   &lt;form&gt;
       <tr>
           <td>Name : &lt;input type="text" name="nm"&gt;&lt;/td>
           <td>&lt;input type="submit" value="save"&gt;&lt;/td>
       </tr>
   &lt;/form&gt;
</table>
<div id="form_result">
</div>

this is my jquery ajax:
Code:
$("#formIn form").submit(function()
{
   $('#form_result').empty();
   $.post('http://MySystem/people/save',$(this).serialize(),function(data)
   {
$('#form_result').html(data);
   });
   return false;
});

i create save method in a class named people, just like this:
Code:
function save()
{
echo $this->input->post('nm');
}

i just want to test data that i input could be out in
<div id="form_result">
</div>
but, it dont display.

is there wrong code in code i write?
bcoz no error display, it make me confuse where my error is.

sorry if i make mistake something.
need ur help all, thanks b4.
#2

[eluser]xeroblast[/eluser]
try this but not yet tested:

jquery
Code:
$("input[type=submit]").onclick(function(){
$.post( 'your/url/save', $("#formIn form").serialize(), function(data){
  $("#form_result").append(data);
});
});

and also, use firebug to know if your ajax query hadnt encounter any errors..
#3

[eluser]Unknown[/eluser]
i try using it, but still not work,
oh ya, i forget, i try this sample above with twitter bootstrap.

n i also try without bootstrap, suddenly it work out.

how's about that buddy?




Theme © iAndrew 2016 - Forum software by © MyBB