/    Sign up×
Community /Pin to ProfileBookmark

Javascript Callback in Mozilla firefox.

Problem with javascript code in Mozilla firefox.

[CODE]
[COLOR=”red”]//Initial Code block[/COLOR]
PhaseID = cboPPPhase.options[cboPPPhase.selectedIndex].value;
WorkflowRequest(PhaseID);

[COLOR=”Red”]//The function[/COLOR]
function WorkflowRequest(PhaseID)
{
[COLOR=”red”] //This is Ajax code block[/COLOR]
Http.get({url: “../ajax/Process.aspx?PhaseID=” + PhaseID , asynchronous:false, callback: WorkflowRequest_callback});
}

[COLOR=”Red”]//The callback function[/COLOR]
function WorkflowRequest_callback(Result)
{
if (Result.readyState==4)
{
if (Result.status==200)// if “OK”
{
WorkflowProcessResult(Result);
}
}
}

[/CODE]

The problem here is that after calling the ajax code i cannot able to call the callback function (WorkflowRequest_callback(Result). The debugger does not come to the call back function.
[COLOR=”red”]This occurs in Mozilla browser and works perfectly in IE.[/COLOR]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@willfindavidauthorJul 14.2008 — [COLOR="Red"]//some part of Ajax code is as below:[/COLOR]
[CODE]
get: function(params, callback_args){
if (!Http.enabled){
//alert("Http: XmlHttpRequest not available.");
return null;
}

var url = params.url;
if (!url)
{
//alert("Http: A URL must be specified");
return null;
}

var method = params.method || Http.Method.Get;
var callback = params.callback;
var async = params.asynchronous;
//alert(async);
if (async == undefined)
async = Http.Asynchronous;

//alert('method : ' + method + "nn" + 'url : ' + url + "nn" + 'async : ' + async)

//alert(async);

var sep = (-1 < url.indexOf("?")) ? "&" : "?"
url = url + sep + "__=" + encodeURIComponent((new Date()).getTime());

// Only one request at a time, please
if ((Http._get.readyState != Http.ReadyState.Uninitialized) &&
(Http._get.readyState != Http.ReadyState.Complete)){
this._get.abort();
}
alert(method +" Url "+ url+" Async "+ async);
Http._get.open(method, url, async);



[COLOR="Red"]Http._get.onreadystatechange = function() {
if (Http._get.readyState != Http.ReadyState.Complete) return;

if (callback_args == null) callback_args = new Array();

var cb_params = new Array();
cb_params.push(Http._get);
for(var i=0;i<callback_args.length;i++)
cb_params.push(callback_args[i]);

if ( callback!=null)
callback.apply(null, cb_params);
}[/COLOR]
//alert(params.body);
Http._get.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
//if (params.body)
// Http._get.setRequestHeader("Content-length", params.body.length);
//Http._get.setRequestHeader("Connection", "close");
//if (params.body)
//alert(params.body);
Http._get.send(params.body || null);

}

}

[/CODE]
Copy linkTweet thisAlerts:
@willfindavidauthorJul 14.2008 — I think the error is somewhere here in the Ajax code coloured red.

In IE the Ajax code executes peoperly but in Mozilla the code doesnot execute.
×

Success!

Help @willfindavid spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...