0

.

Code inside $(document).ready is not being called when another page in the site redirects to the page.

Using Spring MVC

Page 1 url: /location/. This contains the below snippet after the tag. This URL is tagged as the home URL for the site as the user enters from here.

</body>
<script>
$(document).ready(function () {

    initializeCustomerPage();
});

$(window).resize(function() { google.maps.event.trigger(confirm_map,
'resize'); map.setCenter(latlng,15); });
</script>
</html>

There are a lot of operations on this page and then it takes the user to page 2. Upon successful completion of actions in page 2, the user clicks on the home link.

Now, the page 1 loads, but the above JavaScript function does not get executed.

Please let me know if any other code snippet from my sample is needed to help guide.

Firefox console messages seen:

SyntaxError: Using //@ to indicate sourceMappingURL pragmas is deprecated. Use //# instead jquery.mobile-1.3.1.min.js:7 Error: http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js is being assigned a //# sourceMappingURL, but already has one Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help http://xhr.spec.whatwg.org/ confirm.js:52 Empty string passed to getElementById(). jquery.mobile-1.3.1.min.js:6 Use of getPreventDefault() is deprecated. Use defaultPrevented instead. jquery-1.8.2.min.js:2 ReferenceError: rd is not defined main.js line 53 > eval:39

I am using jquery mobile so all the responses are being added to the same DOM. Due to this the original page is in the DOM and hence never being reloaded as it was never taken out. This means that the document is already there so .ready is never triggered. To solve my problem I used 'rel="external"' on the relevant or to force the DOM to be refreshed.

3
  • 3
    There is likely a JS error happening earlier in the page. Open the dev console in your browser and now the error messages. Share them with us if they aren't clear Commented Jun 16, 2014 at 1:24
  • @RobertLevy makes a good suggestion, could also be jQuery's not loading correctly the second time. Commented Jun 16, 2014 at 1:35
  • @RobertLevy, I have added the console output into the main text. None of these I was able to associate to the problem I am having but maybe I am missing something. Commented Jun 16, 2014 at 13:27

1 Answer 1

2

The last line of your console logs indicates the source of the problem: rd is not defined main.js line 53. Check out what's going on in that part of the code.

Sign up to request clarification or add additional context in comments.

6 Comments

The end of body code is here. This is an error from GoogleMaps API. I did not think this was impacting the screen. When I looked it up, it showed up as a Firefox thing.
Updating the complete script at the end of body into the main thread.
your problem is on line 53 of main.js, not the script tag in the HTML
I am switching to Firefox beta 31 to see if that resolves the problem. Now, when I am not using the console or using other browsers too, the script is not getting called. I will still do the upgrade but I do not know if that actually solves my problem. Will update the console output once I upgrade the browser. stackoverflow.com/questions/24174437/…
I got the Firefox 31 beta and this specific message is not showing up in the console. All other messages are still intact :(
|

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.