Jump to content

.post to .ajax


azraelGG

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.