aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes AJAX: Call back handler didn't work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "AJAX: Call back handler didn Watch "AJAX: Call back handler didn New topic
Author

AJAX: Call back handler didn't work

Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Hi All,

I'm using AJAX to store my product info into database.
This code works fine and displayed the proper message:
JSP:

JS:

But when I changed the JSP code from "Image Button" to "Button" type, the behavior changes and call back handler(processStateChange) dosent get called,

JSP:


JS:
And this weird behavior is only on FF, Chrome, But not on IE, On IE both code works and prints result.

Any pointers?



[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
K West
Ranch Hand

Joined: Sep 10, 2008
Posts: 58

Can this be the reason?

Important: If you use the button element in an HTML form, different browsers will submit different values. Internet Explorer will submit the text between the <button> and </button> tags, while other browsers will submit the content of the value attribute. Use the input element to create buttons in an HTML form.

Got it from
http://www.w3schools.com/tags/tag_button.asp

Best Luck


Years teach us more than books.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61232
    
  66

If you want your button to have submit semantics you need to specify type="submit"


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You need to return false to keep the default action from firing.


Eric
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

K West & Bear, thanks for the help, but I'm not submitting a FORM, but calling a JS function on 'onclick()' event.

Eric , your solution works, but with little modification, as

and you said "return false to keep the default action from firing. ", can you elaborate this ?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Return false keeps the default action from happening.

Eric
Dawn Charangat
Ranch Hand

Joined: Apr 26, 2007
Posts: 249
how are you creating the "req" object ??? XMLHttp ??? ActiveXObject ???

The way you create one for MSIE is totally different for other browsers.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

And the default action is "processStateChange()", a call back handler, Am I right ?

Dawn Charangat wrote:how are you creating the "req" object ??? XMLHttp ??? ActiveXObject ???
The way you create one for MSIE is totally different for other browsers.

I think that wouldn't be an issue, still FYI:

Dawn Charangat
Ranch Hand

Joined: Apr 26, 2007
Posts: 249
I can't be sure that this is the problem... but I find some loopholes in the way you create your request object.
Try the below code:


Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

And that's throws an error like,
Error initializing XMLHttpRequest 1.
Error: A script from "http://localhost" was denied UniversalBrowserRead privileges.

Do you really thinks that code makes a difference ??
I just scared, looking at those "msobj" array and setting privileges for "netscape".
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Dawn,

Why in the world would people need to use this:



Also MS does not recommend that you use half of the XMLHTTP values you supply in that array.

Eric
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Still my question is unanswered ? I'm just making it sure.
Eric Pascarello wrote:Return false keeps the default action from happening
Sagar Rohankar wrote:And the default action is "processStateChange()", a call back handler, Am I right ?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
One of the posts above I said: "return false keeps the default action form happening." Another way to say it it cancels the click. Does that make sense yet?

Eric
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Eric Pascarello wrote:Does that make sense yet?

Absolutely, Thanks Eric
 
Don't get me started about those stupid light bulbs.
 
subject: AJAX: Call back handler didn't work