javascript - span tag text not change using JQuery ajax -
i cant give json value span tag using jquery ajax function
var productid = $("#product_id").text(); var city = $("#spn-deliveryloccookies").text(); $.ajax({ url: '/product/est_time', type: 'get', data: { 'city': city, productid: productid }, contenttype: 'application/json; charset=utf-8', success: function (res) { //your success code alert(res); //$("#p_price").html(""); $("#p_price").text(res.ourprice); }, error: function () { alert("some error"); } }); });
after produce result , web page having
i cant give text value in span tag
in ajax function success block there have **alert(res); , work fine produce result**
$("#p_price").text(res.ourprice); not work
you need parse json string javascript object. access properties.
$("#p_price").text(json.parse(res).ourprice);
Comments
Post a Comment