开发者

jQuery, PHP form echo does not work

Could you guys let me know what is wrong below, for some reason, when I click on the delete image, which is supposed to return the echo from dela.php file, but does not.

<script language="javascript" type="text/javascript">
    $(document).ready(function() {
        $('#del_form').ajaxFor开发者_运维知识库m({
            target: '#del',
            success: function() {
                $('#del').fadeIn(40000);
            }
        });
    });
</script>

<div>
    <form action="dela.php" id="del_form" method="post">
        <input type="image" src="del.gif" id="al_del" value="clicked" />
        click the image on the left
    </form>
</div>
<div id="del" style="background-color:#FFFF99; width:200px; height:100px;"></div>

// dela.php
<?
    if ($_POST['al_del']) {
        echo 'variable pass success';
    }
?>


POST variables are based on input names, not ID's, afaik.

Also I'd usually go

if(isset($_POST['al_del']))

But that's a side bar.


You forgot to put the name attribute. changing

<input type="image" src="del.gif" id="al_del" value="clicked" />

to

<input type="image" src="del.gif" id="al_del" name='al_del' value="clicked" />

may fix it.


fadeIn takes duration as milliseconds. Your fade in takes 40 seconds... is this what you want?

Although this is not the problem, you should consider to write

$('#del').fadeIn('slow');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜