- Removes object keys with null values when doing an ajax request

This commit is contained in:
Vlad
2016-07-13 20:24:19 -04:00
parent b58d996ac7
commit 5a7d5ac3f0

View File

@ -1,4 +1,4 @@
define('ajax', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
define('ajax', ['mailpoet', 'jquery', 'underscore'], function(MailPoet, jQuery, _) {
'use strict';
MailPoet.Ajax = {
version: 0.5,
@ -52,6 +52,13 @@ define('ajax', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
var params = this.getParams();
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
if(method === 'get') {
jqXHR = jQuery.get(