0
$.fn.computation = function ()
{

    var a = '5';
    var b='6';
   var op='+';
    $.ajax({
        type: 'POST',
        url: 'http://localhost/default_service/api/Home/calulate_total',
        data: '{"a":' + a +'"b":'+ b + '}',
        contentType: 'application/x-www-form-urlencoded',
        dataType: "json",
        success: (function (a) {
            $("#screen_label1").text(a);
            //$.cookie('history', button_values + '=' + total);
            //button_values = $("#screen_label1").text();

        })


    });

}

i want to pass variables a b and c in data section.. how do i pass those variables.. help me!

  • `data: { a: a, b: b, c: c }` – Arun P Johny Mar 31 '17 at 04:59
  • $.ajax({ data : { foo : 'bar', bar : 'foo' }, }); – Sarika Koli Mar 31 '17 at 05:03
  • [HttpPost] public string calulate_total([FromBody] string a,string b,string op) { string p = a + op + b; return p.ToString(); } //this is the post method i have in my apiController,when the ajax call happens this method will b triggered..but it is not.. i tried passing the variables as u told me to.. still not trigerring – milan mandanna Mar 31 '17 at 05:13
  • exp = { 'value1': ope1, 'op': ope2, 'value2': ope3 } im doing it this way.. and itz working..thanku guys!! – milan mandanna Apr 05 '17 at 13:42

0 Answers0