XML Request에서 object 및 array child argument를 전송할 수 없는 문제 해결

This commit is contained in:
izuzero 2014-12-05 16:45:39 +09:00
parent d4e10dd338
commit c2511530a7
3 changed files with 111 additions and 23 deletions

View file

@ -1474,17 +1474,33 @@ function xml2json(xml, tab, ignoreAttrib) {
// 현 url과 ajax call 대상 url의 schema 또는 port가 다르면 직접 form 전송
if(_u1.protocol != _u2.protocol || _u1.port != _u2.port) return send_by_form(xml_path, params);
var xml = [], i = 0;
xml[i++] = '<?xml version="1.0" encoding="utf-8" ?>';
xml[i++] = '<methodCall>';
xml[i++] = '<params>';
var xml = [],
xmlHelper = function(params) {
var stack = [];
$.each(params, function(key, val) {
xml[i++] = '<'+key+'><![CDATA['+val+']]></'+key+'>';
});
if ($.isArray(params)) {
$.each(params, function(key, val) {
stack.push('<value type="array">' + xmlHelper(val) + '</value>');
});
}
else if ($.isPlainObject(params)) {
$.each(params, function(key, val) {
stack.push('<' + key + '>' + xmlHelper(val) + '</' + key + '>');
});
}
else if (!$.isFunction(params)) {
stack.push('<![CDATA[' + params + ']]>');
}
xml[i++] = '</params>';
xml[i++] = '</methodCall>';
return stack.join('\n');
};
xml.push('<?xml version="1.0" encoding="utf-8" ?>');
xml.push('<methodCall>');
xml.push('<params>');
xml.push(xmlHelper(params));
xml.push('</params>');
xml.push('</methodCall>');
var _xhr = null;
if (_xhr && _xhr.readyState !== 0) _xhr.abort();