jQuery.ajax()'s processData option extension

jQuery.ajax()'s processData option extension

Let users use functions for the processData option for $.ajax() (more importantly for $.ajaxSetup() ) for more advanced handling of data.


Here is what I've came up with:


  1. // Convert data if not already a string
  2. if ( s.data && s.processData && typeof s.data !== "string" ) {
  3.   if (typeof s.processData === "function") {
  4.     s.data = s.processData(s.data)
  5.   }else{
  6.     s.data = jQuery.param( s.data, s.traditional );
  7.   }
  8. }


What do you think?