lundi 31 décembre 2018

javascript code not working for external file

i have javascript code that send data to backend which when i place inline then work fine but when i place in external file it does not work.meanwhile other javascripts is working in external file.

<script>
$('#submit-ajax').click(function(event) {
         console.log('working or not')
         $.post(
                '/order/detail/',
                {
                    'test': 'hi i am here',
                },
                function() {
                  alert( "Data Loaded: " );
                }
         )
         });
</script>

in external file code is:

$(document).ready(function(){
$('#submit-ajax').click(function(event) {
             console.log('working or not')
             $.post(
                    '/order/detail/',
                    {
                        'test': 'hi i am here',
                    },
                    function() {
                      alert( "Data Loaded: " );
                    }
             )
             });
}




Aucun commentaire:

Enregistrer un commentaire