user1960083
user1960083

Reputation: 17

How can I resolve an issue where jQuery does not run until after I refresh the page?

I'm developing a login system using jQuery mobile, javascript and php. The following code does not seem to run until after I refresh the page. How can I resolve this?

$(document).ready(function(){ alert('hello')};

Upvotes: 0

Views: 248

Answers (2)

andleer
andleer

Reputation: 22568

Fairly fundamental with jQuery Mobile that you can't use $(document).read(); Instead:

$(document).bind("pageinit", function() {
    alert('hello');
});

http://jquerymobile.com/demos/1.2.0/docs/api/events.html

Upvotes: 0

VictorKilo
VictorKilo

Reputation: 1870

You are not really giving enough to go off of, but the only reason that a ready function would not run on a page is if the page does not fully load and is therefore not "ready." Really, we would need to see more of your page code to help you at all.

Additionally, you are missing a right-parenthesis which will definitely cause problems.

$(document).ready(function(){ 
    alert('hello');
});

Upvotes: 3

Related Questions