views:

366

answers:

1

I have a little ajax form on my Facebook Canvas Tab Application. If it the form posts successfully, no validation errors, I want to reload the page.

I know that to navigate inside of a Tab Application you need to make sure that all of your links have a relative path relative to your canvas application url. Which all of my links do have. Therefore the post response has a relative path url. But I cannot seem to get the page to reload in the manner that I want.

I have tried the following three methods with no success.

var form = document.createElement('form');
form.setAction(myurl);
document.getElementById('body').appendChild(form);
form.submit();

and

document.setLocation(myurl)

and also

function simulateClick(obj) {
    var evt = document.createEvent("MouseEvents");
    evt.initMouseEvent("click", true, true, window,
0, 0, 0, 0, 0, false, false, false, false, 0, null);
    var canceled = !obj.dispatchEvent(evt);
    if (canceled) {
        // A handler called preventDefault
        console.log("canceled");
    } else {
        // None of the handlers called preventDefault
        console.log("not canceled");
    }
}

Is there a different way to approach this? Could my url be wrong(It has the same relativeness as the url's I am using in the links)? Can I raise a click event for a link using FBJS?

related questions