我是PHP的初学者。
我的网站上有一个表单,这个表单获取特定网站的标题和描述值(带有PRG_Match)。我想添加url输入此表单,当添加url并按Submit按钮时,它会自动获取字段。
例如:
前端代码:
<input name="url">https://testdomain.com/posts/6412</input>
后端代码:
$link = 'input values here';
结果:
表单字段(标题和描述)刷新或使用Ajax。
我是PHP的初学者。
我的网站上有一个表单,这个表单获取特定网站的标题和描述值(带有PRG_Match)。我想添加url输入此表单,当添加url并按Submit按钮时,它会自动获取字段。
例如:
前端代码:
<input name="url">https://testdomain.com/posts/6412</input>
后端代码:
$link = 'input values here';
结果:
表单字段(标题和描述)刷新或使用Ajax。
If you use jQuery, you can use its serialize()
method to get all the form inputs.
$("#form").submit(function(e) {
e.preventDefault();
$.ajax({
type: "post",
url: $(this).attr("action"),
data: $(this).serialize(),
success: function(response) {
$("#result").html(response);
}
});
});
Note, however, that serialize()
won't include the submit button itself. That's only submitted automatically in normal form submissions. If the server expects something like $_POST['submit']
to be set, you have to add it explicitly, e.g.
data: $(this).serialize() + '&submit=true',