dqd3690 2010-07-17 10:52
浏览 21

是忽略代码的浏览器还是服务器?

i made this form:

<form id="form" name="msgform" method="" action="">
<input type="text" size="40" id="msg" name="message"/>
<input type="submit" id="button" name="clicker" value="click" />
</form>

and this jquery script:

$(document).ready(function(){

$("#button").click(function(){

$("#form).submit(function(){


var submision= $("#form).val();

$.post("txt/process.php", submision, function(data){
alert(data);

});

});
});
});

and this is the process.php file:

<?php
echo $_POST['message'] . "";
?>

now when i click the button the form is submited, but it sends it using the GET method because i can see it in the adress bar, but it never gets sent to the php file, and i checked to see if the names are correct and if i specify the POST method it still doesnt go to the php file. is the server or browser ignoring the code? or am i doing the whole thing wrong?

thanks

  • 写回答

3条回答 默认 最新

  • dstbp22002 2010-07-17 10:55
    关注

    You don't need to register the submit event for the form inside the click handler of the button. As it is a submit button it will automatically try to submit the form for which you register the corresponding handler:

    $(function() {
        $('#form').submit(function() {
            // Get all the values from the inputs
            var formValues = $(this).serialize();
            $.post('txt/process.php', formValues, function(data) {
                alert(data);
            });
            // Cancel the default submit
            return false;
        });
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度