Jump to content

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,

});

Edited by stijn0713
Link to comment
https://forums.phpfreaks.com/topic/273421-post-to-ajax/#findComment-1407308
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.