View Full Version : Function parameters, within function parameters

06-06-2011, 11:20 AM

I am making a function that executes code as AJAX readyState's are returned...

If readyState = 3 then I running code through eval but I want to be able to run functions with parameters, within the parameter that is evetually executed by the eval

Heres abit of pseudo code of what I am talking about

function receiveRequest(whileLoading, whenDone) {
// AJAX stuff... blah... blah... blah...
if request is being processed:
if request is done:

// When a button is clicked:
onClick="receiveRequest('alert('loading')', 'alert('finished AJAX request')')"

But this doesn't work because I am escaping the first parameter of 'receiveRequest' in the alert()
but if I use double quote (") I will be escaping the event handler

Is there anyway to get around this / or a better way to fix it?

I haven't used Javascript in agggeeesss and I can barely remember anything anymore - PHP <3

Thanks in advanced.

06-06-2011, 12:30 PM
You might be able to solve it by escaping the inner single-quotes

onClick="receiveRequest('alert(\'loading\')', 'alert(\'finished AJAX request\')')"

06-08-2011, 11:04 AM
Thanks for your help - it worked =)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum