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> Link to comment https://forums.phpfreaks.com/topic/273421-post-to-ajax/ 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. Link to comment https://forums.phpfreaks.com/topic/273421-post-to-ajax/#findComment-1407233 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. Link to comment https://forums.phpfreaks.com/topic/273421-post-to-ajax/#findComment-1407248 Share on other sites More sharing options...
stijn0713 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 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, }); Link to comment https://forums.phpfreaks.com/topic/273421-post-to-ajax/#findComment-1407308 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. Link to comment https://forums.phpfreaks.com/topic/273421-post-to-ajax/#findComment-1407309 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... Link to comment https://forums.phpfreaks.com/topic/273421-post-to-ajax/#findComment-1407310 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.