azraelGG Posted January 21, 2013 Share Posted January 21, 2013 can anyone help me convert post to ajax i want use beforesend option but its only avaliable in .ajax method this is post i want edit function ajaxDelete(id, tablica, tablica_col, trID){ var current = $(trID).closest('tr');//.attr('id'); if(confirm("Potvrdite brisanje")){ $.post("ajax/ajaxDelete.php", {id: id, tablica: tablica, tablica_col: tablica_col }, function(data){ }); beforeSend: current.animate({'backgroundColor':'#fb6c6c'},300); } }; and calling <td><a class="deleteReccord" style="cursor:pointer;" onclick="ajaxDelete('.$stroj['stroj_ID'].', \'stroj\', \'stroj_ID\',this);">Obriši</a></td> Quote Link to comment Share on other sites More sharing options...
Christian F. Posted January 21, 2013 Share Posted January 21, 2013 No need to use AJAX for this. Just return true or false from the function, depending whether or not you want the form to be submitted. You'll have to associate the function with the "onsubmit" handler for the form, and return the value returned from the function, in order to properly halt the submission of the form: <form method="post" onsubmit="return confirmDelete()".... You can also use the .preventDefault() method of the event. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 21, 2013 Share Posted January 21, 2013 He's already using Ajax. He's asking how to switch from jquery's ".post" to ".ajax" Which should be easy by reading the manual. Quote Link to comment Share on other sites More sharing options...
stijn0713 Posted January 21, 2013 Share Posted January 21, 2013 (edited) can anyone help me convert post to ajax i want use beforesend option but its only avaliable in .ajax method I think you meant you want to use post instead of ajax? as you say, beforeSend is only available to .ajax(). Why would you use .post() then? Anyway, i think there are only 2 options, either you use .ajax(), else you use ajaxSetup as it applies to all ajax requests: $.ajaxSetup({ beforeSend: myFunc, }); Edited January 21, 2013 by stijn0713 Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 21, 2013 Share Posted January 21, 2013 I think you meant you want to use post instead of ajax? as you say, beforeSend is only available to .ajax(). Why would you use .post() then? Seriously?? This thread is like watching a Three Stooges sketch. Or Abbott and Costello. Quote Link to comment Share on other sites More sharing options...
stijn0713 Posted January 21, 2013 Share Posted January 21, 2013 Seriously?? This thread is like watching a Three Stooges sketch. Or Abbott and Costello. haha, now i realize my misinterpretation . Probably because the answer is too obvious. Anyway, i don't know the three stooges so can't laugh along with you... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.