tags:

views:

72

answers:

3

Hello,

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.

Thanks Dave

<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';
    }
?>
+8  A: 

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.

Psytronic
+1 correct. al_del needs a `name="al_del"` to work.
Pekka
Generally is the isset() imp, I normally dont use it, anyway, it does not work out by inserting isset()
Jean
it workedthanks...
Jean
No, it's not impertive to use it, however if $_POST['al_del'] had a value of false, or -1 then it would not trigger the echo either, using isset means that even with a false value the if still triggers.
Psytronic
But then that would be a wrong triggering, since I want the if statement to execute if it is true or "1"
Jean
What I mean is that if you're input had a value of false (which is 0, not -1, my fault there), then it would not triggerso <input type="image" value="0" name="al_del" /> This would not result in your form handler echoing "variable pass success". This may not be a problem for this example, but something to be wary of if you are passing user entered inputs, and checking for existance just using `if` over `if isset`.
Psytronic
A: 

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');
Felix Kling
+1  A: 

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.

thinktejas