Add inline javascript with ajax

 Add inline javascript with ajax


$.ajax({
                headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                            },
                type: 'GET',
                url: your_url,
                data:'',
                datatype : 'script',
                success:function(data) {
                    existingscript=document.getElementById("newscript");
                    //remove existing script if exists
                    if(!(existingscript === undefined || existingscript == null)){
                        existingscript.remove();
                    }
                    var head = document.getElementsByTagName('head')[0],
                    script = document.createElement('script');
                    script.id="newscript";
                    script.type = 'text/javascript';
                    script.async = true;
                    var inlineScript = document.createTextNode(data);
                    script.appendChild(inlineScript);
                    head.appendChild(script);
                   
                }
        });

Comentarii

Postări populare de pe acest blog

Process Command Line Arguments in Python

SQL injection with UNION

Docker compose DNS resolution