Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Calling server site script from Javascript using ATLAS

Reply
Thread Tools

Calling server site script from Javascript using ATLAS

 
 
s.bussing@symax.nl
Guest
Posts: n/a
 
      09-23-2006
Hi All,

I'm new to Atlas and I did some programming using AJAX, but I'm
wondering if it is possible to hava a javascript which can call a
server-site function, in my case to write data to the cache, using
AJAX. So I'm not looking for a possibility to wrap-up controls, but
just to call server-site code from ATLAS.

I know this can be done using AJAX, so in my opinion this should also
be possible using ATLAS, or can ATLAS just be used to wrap up controls?

Thx for replies.

 
Reply With Quote
 
 
 
 
Steve C. Orr [MVP, MCSD]
Guest
Posts: n/a
 
      09-24-2006
Yes, this can certainly be done using Atlas.
Atlas can call web services that you write via AJAX.

Here are the details:
http://atlas.asp.net/docs/atlas/doc/...consuming.aspx

--
I hope this helps,
Steve C. Orr
MCSD, MVP, CSM
http://SteveOrr.net


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Hi All,
>
> I'm new to Atlas and I did some programming using AJAX, but I'm
> wondering if it is possible to hava a javascript which can call a
> server-site function, in my case to write data to the cache, using
> AJAX. So I'm not looking for a possibility to wrap-up controls, but
> just to call server-site code from ATLAS.
>
> I know this can be done using AJAX, so in my opinion this should also
> be possible using ATLAS, or can ATLAS just be used to wrap up controls?
>
> Thx for replies.
>



 
Reply With Quote
 
 
 
 
s.bussing@symax.nl
Guest
Posts: n/a
 
      09-24-2006
Hi Steve,

thanks for the reply, but is developing a webservice for such a small
function not a little overkill. Of course I can combine AJAX and ATLAS.
Just a simple function for writing to the cache using an AJAX dll and
for controls use ATLAS.




Steve C. Orr [MVP, MCSD] schreef:

> Yes, this can certainly be done using Atlas.
> Atlas can call web services that you write via AJAX.
>
> Here are the details:
> http://atlas.asp.net/docs/atlas/doc/...consuming.aspx
>
> --
> I hope this helps,
> Steve C. Orr
> MCSD, MVP, CSM
> http://SteveOrr.net
>
>
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) oups.com...
> > Hi All,
> >
> > I'm new to Atlas and I did some programming using AJAX, but I'm
> > wondering if it is possible to hava a javascript which can call a
> > server-site function, in my case to write data to the cache, using
> > AJAX. So I'm not looking for a possibility to wrap-up controls, but
> > just to call server-site code from ATLAS.
> >
> > I know this can be done using AJAX, so in my opinion this should also
> > be possible using ATLAS, or can ATLAS just be used to wrap up controls?
> >
> > Thx for replies.
> >


 
Reply With Quote
 
Laurent Bugnion
Guest
Posts: n/a
 
      09-24-2006
Hi,

http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Hi Steve,
>
> thanks for the reply, but is developing a webservice for such a small
> function not a little overkill. Of course I can combine AJAX and ATLAS.
> Just a simple function for writing to the cache using an AJAX dll and
> for controls use ATLAS.


The simplest implementation of AJAX in .NET is using ASHX Custom
HttpHandlers. It's very simple: In your web site or web application
project, Add New Item / Generic handler.

Then, in the code behind, implement the methods (Studio 2005 gives you a
template).

From the client, use JavaScript and XmlHttpRequest to send the request
and read the response. There are many tutorial online.

Example for a simple asynchronous request:

var oHttp = null;
if ( window.XMLHttpRequest )
{
oHttp = new window.XMLHttpRequest();
}
else
{
if ( window.ActiveXObject )
{
oHttp = new window.ActiveXObject( "Microsoft.XMLHTTP" );
}
else
{
throw "UNSUPPORTED PLATFORM";
}
}
if ( !oHttp )
{
throw "Cannot create XmlHttpRequest";
}

var strQuery = "?param1=value1&param2=value2";
oHttp.open( "GET",
"myHandler.ashx" + strQuery,
true ); // true = async, false = sync

oHttp.onreadystatechange = function()
{
if ( oHttp.readyState == 4 )
{
oHttp = null;
fnCallback( oHttp );
}
}

oHttp.send( null );

Code behind:

In ProcessRequest, use the "context" parameter to extract the
QueryString, and then you can process according to the parameters.

For the Response, if you want to send XML code back, make sure to set
context.Response.ContentType = "text/xml; charset=utf-8";

To save an XML document to the response, use
docResponse.Save(
new XmlTextWriter( context.Response.OutputStream,
context.Request.ContentEncoding ) );


In the JavaScript, the XML code will be available in oHttp.responseXML.
The response is also available in plain text in oHttp.responseText. Also
check the oHttp.status, which contains status like 200 (OK), 500 (Server
error), etc...

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
 
Reply With Quote
 
s.bussing@symax.nl
Guest
Posts: n/a
 
      09-25-2006
Hi Laurent,

thx for the reply. I read some article on the Inet. I was thinking in
the same direction. User ATLAS for the teriffic controls and an AJAX
lib (or CallbackEventHandler but this is limited for IE) for the other
stuff.

Again, thanks guys.




Laurent Bugnion schreef:

> Hi,
>
> (E-Mail Removed) wrote:
> > Hi Steve,
> >
> > thanks for the reply, but is developing a webservice for such a small
> > function not a little overkill. Of course I can combine AJAX and ATLAS.
> > Just a simple function for writing to the cache using an AJAX dll and
> > for controls use ATLAS.

>
> The simplest implementation of AJAX in .NET is using ASHX Custom
> HttpHandlers. It's very simple: In your web site or web application
> project, Add New Item / Generic handler.
>
> Then, in the code behind, implement the methods (Studio 2005 gives you a
> template).
>
> From the client, use JavaScript and XmlHttpRequest to send the request
> and read the response. There are many tutorial online.
>
> Example for a simple asynchronous request:
>
> var oHttp = null;
> if ( window.XMLHttpRequest )
> {
> oHttp = new window.XMLHttpRequest();
> }
> else
> {
> if ( window.ActiveXObject )
> {
> oHttp = new window.ActiveXObject( "Microsoft.XMLHTTP" );
> }
> else
> {
> throw "UNSUPPORTED PLATFORM";
> }
> }
> if ( !oHttp )
> {
> throw "Cannot create XmlHttpRequest";
> }
>
> var strQuery = "?param1=value1&param2=value2";
> oHttp.open( "GET",
> "myHandler.ashx" + strQuery,
> true ); // true = async, false = sync
>
> oHttp.onreadystatechange = function()
> {
> if ( oHttp.readyState == 4 )
> {
> oHttp = null;
> fnCallback( oHttp );
> }
> }
>
> oHttp.send( null );
>
> Code behind:
>
> In ProcessRequest, use the "context" parameter to extract the
> QueryString, and then you can process according to the parameters.
>
> For the Response, if you want to send XML code back, make sure to set
> context.Response.ContentType = "text/xml; charset=utf-8";
>
> To save an XML document to the response, use
> docResponse.Save(
> new XmlTextWriter( context.Response.OutputStream,
> context.Request.ContentEncoding ) );
>
>
> In the JavaScript, the XML code will be available in oHttp.responseXML.
> The response is also available in plain text in oHttp.responseText. Also
> check the oHttp.status, which contains status like 200 (OK), 500 (Server
> error), etc...
>
> HTH,
> Laurent
> --
> Laurent Bugnion, GalaSoft
> Software engineering: http://www.galasoft-LB.ch
> PhotoAlbum: http://www.galasoft-LB.ch/pictures
> Support children in Calcutta: http://www.calcutta-espoir.ch


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
what's wrong calling a Perl/CGI script in Perl/CGI script under Tomcat server? kath Perl Misc 4 04-09-2007 09:21 PM
ATLAS / WEBSERVICES / C# / JAVASCRIPT / SQL SERVER Daniel ASP .Net 0 09-14-2006 10:52 PM
ATLAS. Fire client script from server after ajaxcall wonderu@gmail.com ASP .Net 0 08-30-2006 09:01 AM
Atlas: Calling a javascript method when data arrives Vincent Courcelle ASP .Net 0 05-25-2006 09:53 AM
problem calling perl script from SOAP server perl script pj Perl Misc 3 04-09-2004 10:23 PM



Advertisments