0

I downloaded jquery into my src/.../Resouces/public/js folder and created a simple script called blogcreate.js in the same directory.

My twig template file is attempting to include both js files with the following code:

{% block javascripts %}
    {% javascripts '@BloggerBlogBundle/Resources/public/js/*' %}
        <script type="text/javascript" src="{{ asset_url }}"></script>
    {% endjavascripts %}
{% endblock %}

Blog.js contains the following code:

(function ($){
    alert('Responding!');
});

The trouble is my network tab shows both script but my blogcreate file has a 304 status - which I guess is why my alert box doesn't show up.

Would appreciate it if anyone can tell me what I'm missing.

PS:

I had to include the following in the bundle section of my app/config/config.yml file:

assetic:
    debug:          "%kernel.debug%"
    use_controller: false
    bundles:        [ BloggerBlogBundle ]
0

1 Answer 1

2

304 is "Not Modified" and means that your browser already has a current version of that file. It's not an error.

Your script does not run because its only function is never called.

(function ($){
    alert('Responding!');
});

ought to be either

(function ($){
    alert('Responding!');
})(jQuery);

or possibly:

$(function (){
    alert('Responding!');
});
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Tomalak. I missed that

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.