I'm try to make javascript onclick function in php file.the result is make an alert window in my page.
but nothing happen.please help me.
this is my code:

<script type="text/javascript" charset="utf-8">
    $('#printdata').click(function() {
        datastring = {customer  :'val',
                      person    :'val',
                      address   :'val',
                      phone     :'val'};
        $.ajax({
            type:'POST',
            url:'print.php',
            data:datastring,
            cache:false,

            success:function(){
            alert('?????');
            }
        }):
    }); 
});
</script>

datastring val customer,contact,addres,phone is from option value.
what i'm gonna to do is,when i click button it's gonna appear alert that shows data from i choose before in option select.
thanks

You haven't handled ajax error method. I am sure it will be going there.

Thanks!

If you use your browser's dev tools (javascript console), you may get a better idea of what the problem is. Errors will be shown there.

Member Avatar for diafol

I take it that you've included the jquery library?

You could also try the newer promise callbacks: .done and .fail

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.