The best place to *find* answers to programming/development questions, imo, however it's the *worst* place to *ask* questions (if your first question/comment doesn't get any up-rating/response, then u can't ask anymore questions--ridiculously unrealistic), but again, a great reference for *finding* answers.

My Music (Nickleus)


[SOLVED] php+jquery page loading twice (2 GET requests) instead of once

i was using jquery to set an element's css background-image inside $(document).ready(function()... , and when i removed that code th page would load once instead of twice:

var url ="imgbg");  // get the url string
el.css("background-image", "url('"+url+"')");  // set bgimg url

what was causing the extra page reload/GET request was an empty url string!

putting a simple if-test on url fixed it:

if (url != "") el.css("background-image", "url('"+url+"')");


my fiddle confirming this behavior:

No comments:

Post a Comment