Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ajax

Status
Not open for further replies.

transparent

Programmer
Sep 15, 2001
333
GB
I am writing an Ajax component for .NET.

It is a button, which when clicked makes an Ajax request to the server.

<input type="image" onclick="AjaxRichControls.ImageButton.Clicked('7');" />

The server will return a string that contains javscript function calls i.e. deliminated by |

I want to write a function that will execute all of the returned functions i.e.

<input type="image" onclick="ExecuteJavascript(AjaxRichControls.ImageButton.Clicked('7'));" />

function ExecuteJavascript(string)
{

//split the string into an array based on the delimiator |

// iterate through the array

//execute item in the array
}

How can I execute each javascript command in the array???
 
If you don't have conditions that you have to check after each
function you could create the array and then use setTimeout.

Code:
var myDel = 'f1|f2|f3';

function doFunctions(){
var tmp = new Array();
tmp = myDel.split("|");
tmp = tmp.join('();') + '()';
setTimeout(tmp, 50);
}

Thanks,
--Mark
 
I think the magic solution you're looking for is the use of the eval() function. This is one of the few times it's actually useful.


And what's the deal with all the people that I've seen lately that have asked 100+ questions and have given out little to no stars? This is like the 6th poster in 2 days. I know this subject is sooo taboo on these forums, but surely after a person has spent enough time here on tek-tips to ask 100+ questions they have learned how the star system works. Either that, or all of the 100+ answers they have gotten have been unhelpful. And if that was the case, why would they keep coming back to ask questions?

-kaht

...looks like you don't have a job, so why don't you get out there and feed Tina.
headbang.gif
[rockband]
headbang.gif
 
This is what I have developed, but it doesnt work:

function ExecuteResponse(response)
{

var commands = response.split("|");

for ( var i = 0; i < commands.length; i++ )
{
eval(commands);
}

}
 
why not use IFRAMES???

Known is handfull, Unknown is worldfull
 
I have resolved this - I want passing in a string (idiot)


Why use ajax instead of Iframes?

Because Iframes aren't accessible.

You can't build a decent OO framework around them.

By designing Ajax controls that revert to POST functionality when javascript isn't available, I can build an infrastructure that is both strong, fast and degrades elegantly for users with text browsers for example.
 
>>Because Iframes aren't accessible

i disagree,

you can always use the "parent" method of the iframe to access the methods in the window that implements the IFRAME and always use parent.frames.IFRAME_NAME to access the content of the iframe from the main window.

>>By designing Ajax controls that revert to POST functionality when javascript isn't available

how does that happen? Ajax requires javascript, maybe ASP.NET automatically replaces the info with POST fields accordingly?


>>You can't build a decent OO framework around them
AJAX is client side, OO (if u r referring to .NET) is server side. how is it that going to affect ur OO framework?


Known is handfull, Unknown is worldfull
 
what does this say:
function ExecuteResponse(response)
{
alert(response)
}

Known is handfull, Unknown is worldfull
 
I dont mean accessible from a coding point of view - think section 501.

The framework is written in c# (server side) and automatically generates the clientside javascript - or HTML controls.
 
oh ok,

how about the alert???

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top