使用 Javascript 将值插入到输入而不更改 DOM

问题描述 投票:0回答:1
javascript html dom
1个回答
0
投票

JS是唯一运行在客户端的技术(编程语言)。所以必须使用它。为什么不使用 AJAX 请求来修改你的后端呢?

$.ajax({
    type: "POST",
    url: url,
    data: data,
    success: () => {},
    dataType: "json",
    error: (error, typeError, cc) => {}
});

然后创建一个接受请求的文件,例如在 PHP 中

$field1 = $_POST['field1];
refreshValuesBackend($userReference, $field1, ...$otherFields);

然后创建

refreshValuesBackend()
来更新值。

© www.soinside.com 2019 - 2024. All rights reserved.