I'm receiving some 'body' content from a jquery's json call, where I can get the unique javascript element returned by doing:
script_element = $(data.body)[1]
This equals to:
<script type="text/javascript">
updater('foo', 'bar', {}, '0', constant='');
</script>
So, typeof script_element
returns "object"
And, if I run script_element.innerText
, I can get:
updater('foo', 'bar', {}, '0', constant='');
After receiving this script, what I'm doing right now is just run an eval
on it, but searching around I couldn't get a way to run eval
changing function call params.
What I'm trying to do is change the third
param of the call, in this case the {}
, that can change depending on the return of the json call, so I can't just search for {}
.
I could also do script_element.text.split(',')[2]
for example, and change this text on the fly, but I was thinking there should be a better way to do this.
I don't know if javascript can recognize and treat a "future method call", but still think there should be a better way.
Any idea?