[英]use jquery function with in the response of a ajax call
i use jquery and i do a ajax call. 我使用jQuery,我做一个ajax调用。
var url = "http://localhost:8080/rest/lodgers/" + lodgerId + "/rentamount";
jQuery.ajax({
type: "get",
url: url,
dataType: "json",
success: function(data, status, jqXHR) {
data.optionsPrice = data.optionsPrice.replace(".", ",");
},
error: function(jqXHR, status) {
check401Unauthorized(jqXHR);
}
});
in the success part, replace seem unknow, is there a way to use it? 在成功部分,替换似乎是未知的,有没有办法使用它?
what is the data type of data.optionsPrice? data.optionsPrice的数据类型是什么? .replace() will only work with a string. .replace()仅适用于字符串。
Assuming data.optionsPrice is not null, you could try this: 假设data.optionsPrice不为null,则可以尝试以下操作:
data.optionsPrice = data.optionsPrice.toString().replace(".", ",");
You could also add a null check, just to be sure 您也可以添加一个空检查,以确保
if(data.optionsPrice!=null)
data.optionsPrice = data.optionsPrice.replace(".", ",");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.