【发布时间】:2023-03-28 03:04:02
【问题描述】:
这是我的 JS 代码:
$.when(d1, d2).done(function(v1, v2) {
var url = v1;
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
console.log(url);
}
};
xhr.send("deployment_preference_set_fleet_health_attributes_concurrent_hosts_percentage=31");
});
经过某些处理后,我会得到一个 URL,该 URL 将传递给 v1。
对应URL的HTML内容
<input id="deployment_preference_set_fleet_health_attributes_concurrent_hosts_percentage" max="100" min="0" name="deployment_preference_set[fleet_health_attributes][concurrent_hosts_percentage]" size="3" step="any" type="number" value="30.0" />
% or less of the hosts in the fleet can be deployed to at a time.
我想要的是用特定值更新字段deployment_preference_set_fleet_health_attributes_concurrent_hosts_percentage。
我尝试过使用 xmlhttprequest 但它不起作用。
它在 console.log(v1) 上工作,但我认为 xhr.send () 不起作用,因为我尝试更新的页面没有得到更新
关于如何更新该特定字段的数据的任何建议。
【问题讨论】:
标签: javascript post xmlhttprequest