X10nD
X10nD

Reputation: 22030

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').ajaxForm({
            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';
    }
?>

Upvotes: 2

Views: 893

Answers (3)

tejzpr
tejzpr

Reputation: 995

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.

Upvotes: 1

Felix Kling
Felix Kling

Reputation: 816334

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');

Upvotes: 0

Psytronic
Psytronic

Reputation: 6113

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.

Upvotes: 8

Related Questions