My JavaScript code is hardly an Ajax request that expects XML to be returned from the source code. The back-end can return execute_callbackas one of the XML tags, for example:
<?xml version="1.0" encoding="windows-1251"?>
<response>
<execute_callback>
<function_name>someFunction</function_name>
</execute_callback>
</response>
And everything is in order, as far as you know the exact number of parameters expected by this callback. But what if the back-end returned
<?xml version="1.0" encoding="windows-1251"?>
<response>
<execute_callback>
<function_name>someFunction</function_name>
<param>10.2</param>
<param>some_text</param>
</execute_callback>
<execute_callback>
<function_name>otherFunction</function_name>
<param>{ x: 1, y: 2 }</param>
</execute_callback>
</response>
How to pass parameters 10.2 and 'some_text' to someFunctionand JSON {x: 1, y: 2} to otherFunction?
I know an ugly solution (using a function arguments), but I'm looking for a beautiful one.
: XML - :) , , - , JavaScript. Python, :
def somefunc(x, y):
print x, y
args = { 'x' : 1, 'y' : 2 }
somefunc(**args)
JavaScript.