View Full Version : doubts using YAHOO.util.Connect?
franklt69
8 Mar 2007, 8:50 AM
I wonder is possible to fill responseText in object YAHOO.util.Connect from asp.net?
kind regards
Frank
tryanDLS
8 Mar 2007, 10:30 AM
Not sure what you're asking here. It doesn't matter what the server technology is. When a response is received from the server, YAHOO.util.Connect processes it and populates the response object with what comes back (text and/or xml). You can verify this by stepping thru the code in a debugger - it's very clean and easy to follow. Either your request works or it doesn'tm but processing flows thru Connect.handleTransactionResponse()
franklt69
8 Mar 2007, 3:32 PM
Thanks tryanDls, the doubt come from http://www.yui-ext.com/forum/viewtopic.php?t=3312
when I am using YAHOO.util.Connect I have two functions
sucess and failure
var hcallback={
success: saveSucess,
failure : responseFailure
};
YAHOO.util.Connect.asyncRequest('POST', "/Handler1.ashx", hcallback, xmlSearch)
the doubt is if YAHOO.util.Connect begin a transaction and in the server an exception is raise, then
YAHOO.util.Connect populates the response object with what comes back (text and/or xml) in asp.net is an complete html page for default, then in the client the function responseFailure is triggered but I can't show it in an alert,
but if I want send a message from the server (not complete html page) and not raise an exception then I have trouble because the function responseFailure isn't triggered, I mean the saveSucess function is triggered, I can parse the response in the saveSucess fuction and detect if is an error or not but I think is wrong this approach.
I would like to know if someone using asp.net show a customize error from the server in an alert message in client.
kind regards
Frank
tryanDLS
8 Mar 2007, 4:42 PM
You seem to be asking the same question as you did in the other thread. Look at what Connect does to determine whether you have a good/bad response. You need pass a statuscode that indicates an error. The ASP.Net Response object has a property you can set to do this.
franklt69
9 Mar 2007, 5:23 AM
Thanks again TryanDls I know how check the status code in the client, and how from the server I can change the status code for instance if I set:
try
{
Stream requestStream = context.Request.InputStream;
using( StreamReader sr = new StreamReader(requestStream, System.Text.Encoding.UTF8))
{
dosomething(); //here I raise an exception
context.Response.Write(result);
}
}
catch (Exception e)
{
context.Response.Status = "14000";
}
but I don't know how from sever I can set a message that populate response.responseText of YAHOO.util.Connect, becouse in it always I get the complete html error.
a little example how set in the response.responseText the message that I want from asp.net is welcome.
kind regards
Frank
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.