Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Json/JavaScript problem

 
Minh Nguyen Hung
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65223
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With all those returns, how can you tell if it's returning try or false? Have you tried using a JavaScript debugger?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65223
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please explain the thinking behind this:

Why bother setting result if it's never going to be used?
 
Minh Nguyen Hung
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65223
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65223
95
IntelliJ IDE Java jQuery Mac Mac OS X
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic