javascript - Posting a form with jQuery and want to change the submit button after click -
here's code i'm using :p did not work!
and anyways hell "it looks post code please add more details" ?
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"> </script> <script> $(document).ready(function(){ $("#button").click(function(){ $("#button").submit(sendform) }); function sendform() { $.post('post.cfm',$("#button").serialize(),function(data,status){ $("#result").html(data) }); return false } $("#button").html("friend request sent"); }); }); </script> </head> <body> <form id="button"> <input type="submit" value="add friend"> </form>
you try this:
var sendform = function() { $.post('post.cfm',$("#button").serialize(),function(data,status){ $("#result").html(data) }); var request = $.ajax({ type:'post', datatype:'json', url:'post.cfm', data:{ data: $('#button').val() }, success:function(data){ console.log(data); // }, error:function(data){ console.log(data); // } }); request.done(function(data){ alert("friend request sent"); }); return false; } $(document).ready(function(){ $("#button").click(function(){ $("#button").submit(sendform) });
Comments
Post a Comment