jquery - Need to update the check box value to db table when i click the checkbox() without post back in MVC2 -


<input type="checkbox" name="n" value=1 /> <input type="checkbox" name="n" value=2 /> <input type="checkbox" name="n" value=3 /> 

i have above checkbox when select need update db table without post back. please explain.. if possible can jquery or ajax method solve problem

you have sort of request server, whether it's post form button or ajax post or request.

form button:

<form action="/myapp/handleclick/" method="post">     <input type="checkbox" name="selectedobject" value="cbvalue"/>     <button type="submit">submit</button> </form> 

or, ajax (with jquery):

 jquery('input[name=selectedobject]').click(function() {      jquery.ajax({          url: '/myapp/handleclick/',          data: {              selectedobject: this.value,          }          success: function() {              // process success data...          }      });  }); 

then controller:

public class myappcontroller : controller {     [httppost]     public actionresult handleclick(string value)     {         // handle persisting value database...          // if posting         return redirecttoaction("otheraction");          // if ajax         return json("success!");     } } 

that's simplest example - can't answer more without more details you're trying accomplish.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -