c# - How do I access methods when using a jquery script? -


i have jquery script , whenever drop-downlist value changes, supposed take value , pass method gets value , calculates price based on value , in end sets label new value.

here jquery script:

@section pagescripts{ <script type="text/javascript">     $(document).ready(function () {         $('#papertypejlist').change(function () {             // trying figure out how pass value following method         });     }); </script> } 

here method i'm trying call inside of jquery script:

public decimal getnewprice(string dropdownvalue)     {         // value , return decimal         return 0;     } 

try using jquery ajax html :

 <label id="pricelabel"></label> 

javascript

   $(document).ready(function () {     $('#papertypejlist').change(function () {         $.ajax({             type: "get",             url: "/home/getnewprice?dropdownvalue=" + this.value,             async: true,             success: function (result) {                 document.getelementbyid('pricelabel').innerhtml = result;             }         });     }); }); 

controller

public decimal getnewprice(string dropdownvalue)     {         // value , return decimal         return 5.72m;     } 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -