- Removes object keys with null values when doing an ajax request
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
define('ajax', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
|
define('ajax', ['mailpoet', 'jquery', 'underscore'], function(MailPoet, jQuery, _) {
|
||||||
'use strict';
|
'use strict';
|
||||||
MailPoet.Ajax = {
|
MailPoet.Ajax = {
|
||||||
version: 0.5,
|
version: 0.5,
|
||||||
@ -52,6 +52,13 @@ define('ajax', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
|
|||||||
var params = this.getParams();
|
var params = this.getParams();
|
||||||
var jqXHR;
|
var jqXHR;
|
||||||
|
|
||||||
|
// remove null values from the data object
|
||||||
|
if (_.isObject(params.data)) {
|
||||||
|
params.data = _.pick(params.data, function(value) {
|
||||||
|
return (value !== null)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// make ajax request depending on method
|
// make ajax request depending on method
|
||||||
if(method === 'get') {
|
if(method === 'get') {
|
||||||
jqXHR = jQuery.get(
|
jqXHR = jQuery.get(
|
||||||
|
Reference in New Issue
Block a user