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 firebug 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**

image link

$("#p_price").text(res.ourprice); not work

you need parse json string javascript object. access properties.

  $("#p_price").text(json.parse(res).ourprice); 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -