0

Why alert("Test1") is executed, while alert("Test2") is not executed? P.S. Currently I'm not using json data.

<script>
$(document).ready(function() {
    var param = 10;
           $.getJSON(
                       'modules/mod_scheduler/updateList.php?param'+param,
                       function(data)
                       {
                           alert("Test1");
                           find_optimal_schedule();
                       }
           );
    });
</script>

<script language="javascript">
function find_optimal_schedule() {
    alert("Test2");
    //...
}
</script>
4
  • Please show the rest of the find_optimal_schedule() function. If there is a syntax error in the part you don't show it would stop the function from running and thus not alert "Test2". Commented Aug 12, 2012 at 22:23
  • @nnnnnn: Currently this function is empty. It contains only alert("Test2"); which is not displayed. Commented Aug 12, 2012 at 22:25
  • Oh, OK - I guess I assumed (incorrectly) that //... represented more code. But if that's the whole function and the whole of that script block I don't see any reason why it wouldn't work. Commented Aug 12, 2012 at 22:49
  • Could you post the whole page, including everything? Commented Aug 14, 2012 at 10:05

1 Answer 1

2

I'm not sure about it, but try changing this bit:

<script language="javascript">

into:

<script type="text/javascript">

And see if it runs.

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

8 Comments

I changed this line, but it did not help solve the problem. Maybe it does not see the function find_optimal_schedule()??
Have you tried using Firebug on Firefox and see what error appears in the Console?
Even the following does not work: $(document).ready(function() { alert("Test1"); find_optimal_schedule(); alert("Test3"); }); I can see only "Test1"
There's likely a syntax error in find_optimal_schedule(), in the part of the code you haven't shown.
What happens when you run find_optimal_schedule() directly in the Firebug console?
|

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.