form onsubmit with fb.end

Page: 1

Author Post
Member
Registered: Jan 2012
Posts: 21
I guess it is hard to explain my situation, but I will try.

We have corporate app in PHP. In latest version of Chrome in Windows XP systems we start to notice some strange things. We have an form in FB who opens with href and standard class="floatbox". Onsubmit we placed fb.end('?id=1000'). The id is pointer to php file that is in use and during this operation it is always the same.

When user submits the form it should close FB, update database and display final table with updated database data.

All we get is table with data. Code that it should be triggered by $_REQUEST['button_id'] is not executed or the form data is lost somewhere.

If we leave the code with onsubmit fb.end it works in Chrome on Win7, IE on XP or Win7 and Chrome in Linux. The exception is Chrome on XP. We start to notice this with Chrome 19 and 20. Before it was OK.

FB version is 3.5.2

How could we debug this to find where the form parameters are lost?
Administrator
Registered: Aug 2008
Posts: 3382
I don't think anything is getting lost. I think you just have a timing issue. You are simultaneously submitting the form and closing the floatbox with a page refresh. It's a complete luck-of-the-draw as to whether the submit will complete prior to the page refresh or whether the page refresh will occur before the submit has been processed.

You should make the closing of the floatbox and the refreshing of the page synchronous with the submit to ensure that it occurs afterwards. There's a couple of ways to do this that come to mind. One would be to return a script element from the submit action and place the fb.end call in this returned script element. Another approach would be to submit the form with an fb.ajax call and run fb.end as the success callback when that ajax submission completes.

Either way, the objective is to sequence the submit, end and refresh and not just fire them all at once and hope for the best in terms of their completion order.
Member
Registered: Jan 2012
Posts: 21
We previously used your first approach and we didn't like it because of scattered code for managing FB.

We try to write cleaner code and we failed.

Now we tried the second one with type:ayax and we don't know why we didn't done it before. So for us this is the best one.

Thanks.

Page: 1