File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Json/JavaScript problem 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 "Json/JavaScript problem" Watch "Json/JavaScript problem" New topic
Author

Json/JavaScript problem

Minh Nguyen Hung
Greenhorn

Joined: Mar 16, 2012
Posts: 5
I have an insert form, which only allow submit if all the input is validated. But in my case, even though the form still displays the errors, but it still allow the submit button to work. Here is my code:

The checkAll() function for submit form validation.


Java Servlet on getJson link.



I try to use firebug to debug what wrong, but i can't get into the getJson and i don't know if it will return true/false or not.
Please someone helps me to fix this issue. Thanks for advance
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

With all those returns, how can you tell if it's returning try or false? Have you tried using a JavaScript debugger?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

Please explain the thinking behind this:

Why bother setting result if it's never going to be used?
Minh Nguyen Hung
Greenhorn

Joined: Mar 16, 2012
Posts: 5
Ah it's just my extra code to test for old codes but i forgot to remove it, so don't mind it sir.

About all those return, my idea is if it can't pass at one if check, it will break then display current error.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

OK, clean up the code first. Messy code can hide a multitude of sins.

Then use a JavaScript debugger to see if the value false is being returned in the cases when you don't want the form to submit.
Minh Nguyen Hung
Greenhorn

Joined: Mar 16, 2012
Posts: 5
Thanks for your reply Bear, it seems i got messed up about how callback works in getJson function. So i decide to change to $.ajax and set aysnc:false. Now the code works fine.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Json/JavaScript problem
 
Similar Threads
unable to connected to next page
Error DefaultActionInvocation
.getJSON not returning any response.
I want to implement editable autocompleter in struts2 using jquery.
json object send to JSF backing bean to xhtml page