473,473 Members | 4,176 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Identify Ajax proc name from a string variable

Hello all-

The best way to describe what im trying to accomplish is with a code
snippet. Im using the free .NET ajax library.

<script language='javascript'>
function proc1()
{
myFunc("MyCodeBehind.MyAjaxProc");
}
function myFunc(procName)
{
procName("My Parameter", processMyFunc);
}
function processMyFunc(response)
{
// Process response from the server
}
</script>

So im essentially invoking an Ajax function , but I cant explicitly use
the name of it like so

MyCodeBehind.MyAjaxProc("My Parameter", processMyFunc);

That line would work fine. Clearly though, this doesnt work

var procName = "MyCodeBehind";
procName("My Parameter", processMyFunc);

If anyone knows how to accomplish this, im dyin to know!

Apr 4 '06 #1
3 1113
Hoss wrote:
[...]
<script language='javascript'>
<script type="text/javascript">
function proc1()
{
myFunc("MyCodeBehind.MyAjaxProc");
}
function myFunc(procName)
{
procName("My Parameter", processMyFunc);
}
function processMyFunc(response)
{
// Process response from the server
}
</script>

So im essentially invoking an Ajax function , but I cant explicitly use
the name of it like so

MyCodeBehind.MyAjaxProc("My Parameter", processMyFunc);

That line would work fine. Clearly though, this doesnt work

var procName = "MyCodeBehind";
procName("My Parameter", processMyFunc);

If anyone knows how to accomplish this, im dyin to know!


Global functions are methods of the Global Object.
In global context, `this' refers to the Global Object.

this[procName]("My Parameter", processMyFunc);
PointedEars
Apr 4 '06 #2
Alright - figured out the best way to do this.

var string = "var response = MyCodeBehind.MyAjaxProc('my parm')";
eval(string);
// do whatever with response variable

Why didnt I ever think of that =p

Apr 4 '06 #3
Hoss wrote:
Alright - figured out the best way to do this.
Quite the contrary.
var string = "var response = MyCodeBehind.MyAjaxProc('my parm')";
eval(string);
// do whatever with response variable

Why didnt I ever think of that =p


Because everybody (here) recommends against this nonsense?

<URL:http://jibbering.com/faq/#FAQ4_40>
PointedEars
Apr 4 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: NevilleDNZ | last post by:
Can anyone explain why "begin B: 123" prints, but 456 doesn't? $ /usr/bin/python2.3 x1x2.py begin A: Pre B: 123 456 begin B: 123 Traceback (most recent call last): File "x1x2.py", line 13,...
10
by: trpost | last post by:
I am using ajax / php where I am looking up some info from the database and populating a select list dynamically, however I am running into some sort of size limitation with the ajax.response...
7
ak1dnar
by: ak1dnar | last post by:
Hi, I got this scripts from this URL There is Error when i submit the form. Line: 54 Error: 'document.getElementbyID(....)' is null or not an object What is this error. Complete Files
1
by: geevaa | last post by:
http://www.phpbuilder.com/columns/kassemi20050606.php3 XMLHttpRequest and AJAX for PHP programmers James Kassemi Introduction: Although the concept isn't entirely new, XMLHttpRequest...
1
nmm32
by: nmm32 | last post by:
I am trying to use Ajax with JSP to populate a 2nd drop down list based on the chosen option of the first one. I am getting the error "Object Expected" on the line 13-14 of the HTML: <script...
2
by: shivendravikramsingh | last post by:
hi friends, i m using a ajax function for retrieving some values from a database table,and display the values in required field,my prob is that the ajax function i m using is working f9 once,but if...
7
by: Andrew Poulos | last post by:
If I have code that looks like this ajax = function(str) { var val = ""; // do some stuff here return val; }; var foo = ajax("string");
0
by: crocodilu2008 | last post by:
JSON vs. XML JSON and XML are basically used for the same purpose—to represent and interchange data. I'll try to show you why you might want to use JSON rather than XML in an AJAX context by showing...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.