0

i use the following script, and i think it needs to do the following:

When someone clicks the a href link with ID "submit" in the Form, it needs to call documentblock.inc.php and alert the data thats been echoed in documentblock.inc.php

But i get no alerts. What do i do wrong?

            <form action="<?php echo $domein.'/mijnpagina/bestanden/downloaden/' ?>" method="post" name="downloaditem">
                    <label><input type="checkbox" id="checker_tiny" value="ja" name="blokkeer"/> Bestand blokkeren na downloaden</label>
                    <input name="docId" id="docId" type="hidden" value="<?php echo $fetch_bestand['id']; ?>">
                    <input name="downloaditem" type="hidden" value="akkoord">
                    <a href="#" id="submit" class="button-pink">Bestand downloaden</a>
                    </form>
                    <div class="clear"></div>
                </div>

                <script>
                $(function () {
                    $('#submit').on('click', function () {
                        // stop form submission first
                        // GET VALUE OF APPID
                        var appid = $("#docId").val()
                            // GET JSON FROM PHP SCRIPT
                            $.ajax({
                                type : 'POST',
                                url : '/includes/documentblock.inc.php',
                                data: {'appid':appid}, 
                                success : function () {
                                    alert(data);
                                },
                                error : alert('test')
                            });
                    });
                });
                                    </script>     

documentblock.inc.php:

<?php echo "test"; ?>

2 Answers 2

2

You need to pass data to your success function:

success : function (data) {
    alert(data);
}
Sign up to request clarification or add additional context in comments.

Comments

0

Did it like this and it works!

 <script>
function submitme(){
var docId=document.getElementById("docId").value;
var blockId=$("input[name=blokkeer]:checked").val();

$.ajax({
        type: 'POST',
        url: '/includes/documentblock.inc.php',
        data: 'docId='+docId+'&blockId='+blockId,
        success: function(msg){
            if(msg){
                document.getElementById("something2").innerHTML=msg;
            }
            else{
                return;
            }
        }
    });
} </script>  

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.