Skip to content
Snippets Groups Projects
Commit c68358c8 authored by totten's avatar totten
Browse files

CRM-13121 - CRM.api - Always encode data with JSON

The query-string encoder misencodes empty arrays -- and most likely
misencodes other things.

----------------------------------------
* CRM-13121: CRM.api cannot call "replace" with empty list
  http://issues.civicrm.org/jira/browse/CRM-13121
parent 870a9447
No related branches found
No related tags found
No related merge requests found
......@@ -86,8 +86,7 @@ var CRM = CRM || {};
*/
CRM.api = function(entity, action, params, options) {
// Default settings
var json = false,
settings = {
var settings = {
context: null,
success: function(result, settings) {
return true;
......@@ -102,7 +101,7 @@ var CRM = CRM || {};
}
return settings.success.call(this, result, settings);
},
ajaxURL: 'civicrm/ajax/rest',
ajaxURL: 'civicrm/ajax/rest'
};
action = action.toLowerCase();
// Default success handler
......@@ -122,24 +121,11 @@ var CRM = CRM || {};
return true;
};
}
for (var i in params) {
if (i.slice(0, 4) == 'api.' || typeof(params[i]) == 'Object') {
json = true;
break;
}
}
if (json) {
params = {
entity: entity,
action: action,
json: JSON.stringify(params)
};
}
else {
params.entity = entity;
params.action = action;
params.json = 1;
}
params = {
entity: entity,
action: action,
json: JSON.stringify(params)
};
// Pass copy of settings into closure to preserve its value during multiple requests
(function(stg) {
$.ajax({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment