[英]span tag text not change using JQuery ajax
i cant give json value to span tag actually i am using jquery ajax function 我不能给json值来覆盖标签实际上我正在使用jquery ajax函数
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 that it produce result 之后产生结果
and the web page having a
并且网页上有一个
i cant give the text value in to span tag 我无法在span标签中提供文本值
in my ajax function success block there have **alert(res); 在我的ajax函数成功块中,有** alert(res); and it work fine it produce result**
而且效果很好,可以产生结果**
$("#p_price").text(res.ourPrice); $(“#p_price”)。text(res.ourPrice); not work
不行
You need to parse the json string to javascript object. 您需要将json字符串解析为javascript对象。 Then only you access its properties.
然后只有您访问它的属性。
$("#p_price").text(JSON.parse(res).ourPrice);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.