jquery - Invoke two different actions with same url in ajax call -
how invoke 2 different action methods based on parameters supplied in ajax request, url should same ex :
        public actionresult method1(int a)         {              return json(true);         }          public actionresult method2(int b, int c)         {             return json(true);         }   sample url : /controller/method parameters supplied different , corresponding action method should invoked
in javascript doing ajax call check on parameter , decide url this. (in pseudocode):
<script> function yourajaxkcall(param1, param2, param3){   string url;   if(param1 === someexpectedresult){     url = '@url.action("method1", "controller")';     data = param2;   }   if(param1 === someotherexpectedresult){     url = '@url.action("method2", "controller")';     data = param2, param3 (do proper converting json here)   }   'doyourajaxcall' }  </script>      
Comments
Post a Comment