jquery - After textbox field loosing focues? -


i new ajax/jquery. developing application takes loan number input. when ever textbox field loose focus should display information particular loan getting information database.

i developing in mvc. view consists

loannumber = textboxfield. contact name = textboxfield phone = textboxfield. 

below sample code tells whether loan number exists or not.

 $("#loannumber").blur(function () {                 var num = $("#loannumber").val();                 var status = $("#divstatus");                 $.post("/fnmaimport/checkloannumber", { loannumber: num },                     function (data) {                         if (data == true) {                             status.html("<font color=green>'<b> loan number " + num + "</b>' available!</font>");                         } else {                             status.html("<font color=red>'<b> loan number " + num + "</b>' not available!</font>");                                               }                     });             }); 

now question is, need write new method in controller retrieves information database , make ajax call in if condition true?

just use 1 controller method like...

/fnmaimport/getloannumber

have return information database if num exists or return false if not.

the controller return json like.

{     loadnumber: ####,     result: true|false, /* whether exists or not */     name: "asdfadsfadsf",     date: "####-##-##" }   $.post("/fnmaimport/getloannumber", { loannumber: num },                 function (data) {                     if (data.result == true) {                         status.html("<font color=green>'<b> loan number " + num + "</b>' available!</font>");                         alert(data.name + " " + data.date /* etc */);                     } else {                         status.html("<font color=red>'<b> loan number " + num + "</b>' not available!</font>");                                           }                 }); 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -