如何从表单中获取数据并通过文本中的变量加载php

时间:2018-03-14 22:42:17

标签: javascript php jquery html

如何从表单中获取数据并通过单击按钮在文本中按变量加载php?

我的代码:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<script>
$(document).ready(function(){
    $("#GEPLeach").click(function(){
        $("#EPLeach").hide();
        $("#EPLeached").show();
        $.get("lc.php", function(data){document.getElementById("EPLeached").innerHTML=data;});
    });
});
</script>

<form id="EPLeach">
<input name="type" type="radio" value="keyword" checked>
<input name="type" type="radio" value="URL">
<input type="text" name="input">
<input id="GEPLeach" type="submit" value="Leach">
</form>
<textarea id="EPLeached" hidden></textarea>

1 个答案:

答案 0 :(得分:0)

使用第二个参数将表单值作为参数发送到SELECT c.clientID, c.clientName, b.jobNum, b.startDate FROM Client c INNER JOIN Bricklayers b ON c.clientID = b.clientID WHERE c.clientCity IN ('Charlotte','Raleigh','Wilmington');

$.get()

您还需要在事件处理程序中使用$.get("lc.php", $("#EPLeach").serialize(), function(data) { $("#EPLeached").html(data); }); 来阻止正常提交表单,或者将按钮更改为event.preventDefault();