jquery,发布多个变量

标签 jquery

我是 jquery 的新手,并尝试修改 php 学院的基本脚本。

jquery 脚本是:

<script type="text/javascript">
function get() {
    $.post('getpeopleinjobs.php', {
        postvarfname: form.firstname.value,
        postvarlname: form.d = surname.value
    }, function(output) {
        $('#age').html(output).show();
    });
}
</script>

我的表单代码是:

    <form name="form">
    <input type="text" id="firstname">
    <input type="text" id="surname">
    <input type="button" value="get" onclick="get();">
    </form>

当我只传递一个变量并且我的代码片段是:

$.post('getpeopleinjobs.php', {
    postvarfname: form.firstname.value
}

然后我尝试使用

添加第二个变量
$.post('getpeopleinjobs.php', {
    postvarfname: form.firstname.value,
    postvarlname: form.d = surname.value
}

它现在无法在 Internet Explorer 中运行,但有趣的是它可以在 Chrome 中运行?

对初学者有什么建议吗?=

最佳答案

你的概念是正确的,但似乎有一个小错误

//Posted Code
$.post ('getpeopleinjobs.php',{postvarfname: form.firstname.value,postvarlname: form.d=surname.value}
// Fixed Code
$.post ('getpeopleinjobs.php',{postvarfname: form.firstname.value, postvarlname: form.surname.value}

关于jquery,发布多个变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11437086/

相关文章:

javascript - 使用 Material Design Lite 错误确认密码验证

jquery - 不寻常的 3 列一页网站 - 只是中心列滚动

javascript - 在焦点上显示数据列表的所有选项

javascript - 具有滑动功能的导航中的 anchor 链接跳得太远

javascript - 将元素的 ID 传递给 jquery 函数

jquery - 如何将一个事件仅与一个对象关联? jqplot

javascript - 单击 ul > li 仅在第一次有效

javascript - 我根据 jQuery 中的用户输入创建了一个网格(div),如何重置并重新开始

javascript - 如何检测 Angular 4中的浏览器后退点击

javascript - 未显示所选文件名