views:

82

answers:

3

I seem to be having a problem with this script, it stops after alert 5.

var _v = 0;
var _v2 = 1;
function landscapeUpdate(){
    alert("1");
    var wrapperId   = '#gameWindow';
    alert("2");
    var postFile    = 'game_window.php';
    alert("3");
    _v++;
    alert("4");
    _v2++;
    alert("5");
    $.post(postFile, { v2: _v2 , v: _v}, function(data) {
        alert("6");
        $(wrapperId).html(data);
        alert("7");
    });
}
+2  A: 

This should be easy to debug with Firebug. You'll see javascript errors as well as the HTTP requests to know if they are failing as well.

Because, with a cursory review, nothing looks wrong with your code.

Peter Bailey
+1  A: 

Define "it stops".

The jQuery $.post() function executes it's callback only on request success (i.e. HTTP "200 OK" status). You may not be getting this status.

To have a callback executed on error as well, use something like this:

$.ajax({
  type: "POST",
  url: postFile,
  data: { v2: _v2 , v: _v},
  success: function(msg){
    alert("6");
    $(wrapperId).html(data);
    alert("7");
  },
  error: function(hxr, textStatus, errorThrown) {
    alert("Oops, server said: " + hxr.statusText);
  }
});
Tomalak
A: 

Solved my own question, turns out it was a very silly mistake, I specified the wrong file path to game_window.php

thanks anyway.

Ryan