By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,358 Members | 1,278 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,358 IT Pros & Developers. It's quick & easy.

Exception handling for Missing Function

P: n/a
Hi All,

I have the following button in my page

<input type="button" value="Submit" onClick="ajaxCall(
{
url:'test.php',
method:'POST',
type:'HTML',
placeholder:'placeholder',
custom_function_start:getStart
});"
>
When I submit the page the function ajaxCall({obj}) is called
with the object parameter.

In the object I have a member custom_function_start which
describes a custom function.
My question is if I failed to describe the function
getStart() I should throw an error "Please Describe the Custom
Function".

Here what happen is when I submit all the values are being
assigned for the curresponding members (ie 'test.php' to url, method
='POST' and so on ) Now when it comes to custom_function_start it
is searching for the custom function getStart since it it not
described , The script terminates without any error message.

What I need is if there is no such function I should give a pop up
message to the user to describe the function.

Is it possible.
Thanks and Regards
Moses

Feb 23 '07 #1
Share this Question
Share on Google+
3 Replies

P: n/a
VK
On Feb 23, 10:01 pm, "Moses" <mosesdinaka...@gmail.comwrote:
My question is if I failed to describe the function
getStart() I should throw an error "Please Describe the Custom
Function".
Runtime error "Undefined identifier" will be thrown any way without
your participation: at the moment of trying to execute
custom_function_start:getStart
- if getStart is not defined

<input type="button" value="Submit" onclick="
if (typeof getStart == 'function') {
ajaxCall(
{
url:'test.php',
method:'POST',
type:'HTML',
placeholder:'placeholder',
custom_function_start:getStart
});
}
else {
myErrorHandler('getStart not defined');
}">

Feb 23 '07 #2

P: n/a
Hi

Thanks for your response,

But actually I am trying to have a framework for ajax, So I dont
want to have a if condition within onClick I am trying to make it
simple.

Is there any other way.
Aging one more issue is also there.

Now we have a
funciton getStart()
{

//The values needed for this function is generated only after
calling the ajaxCall() , So getStart should be executed only after
ajaxCall()
}
But here what happens is before calling the ajaxCall() function
initaially getStart() is called and throwing errors 'Object Excepted'
and so on based upon the code.
To avoid this I am doing like this

funciton getStart()
{
if(ajax_call_executed) // This is a global variable which
describes weather function ajaxCall() is executed or not.
{
}
}
Is there any better way to do.
I welcome all your suggestions.
Thanks and Regards
Moses



Feb 24 '07 #3

P: n/a
hi

I have made a mistake in the above post

(ie) I cant even use the global variable ajax_call_executed
So this is wrong

funciton getStart()
{
if(ajax_call_executed) // dosent work throws error
{

}
}
Moses

Feb 24 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.