CodeIgniter Forums
ajax jquery post not working - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: ajax jquery post not working (/showthread.php?tid=55732)



ajax jquery post not working - El Forum - 11-07-2012

[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.


ajax jquery post not working - El Forum - 11-07-2012

[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..


ajax jquery post not working - El Forum - 11-08-2012

[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?