Is it possible to do a simple javascript call to the server?

4 posts, 0 answers
  1. LeBear
    LeBear avatar
    233 posts
    Member since:
    May 2006

    Posted 11 Mar 2008 Link to this post

    I would like to be able to perform a simple call to the server just to get some information.  The simplest example of this is that I would like to issue a call from the client like this:

    myBoolVar = serverIsThereNewDataForMe(MyID);

    or

    myStringVar = serverWhatIsYouFavoriteColor();

    I specifically want to be able to ask the server for some simple data without having to incur the overhead of the normal Ajax call where the entire page script is run.  The reason for this is I might be making a call back to the server every second or two and I'd like to optimize this to be as simple as possible with as little network traffic as possible.

    Thanks.
  2. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 14 Mar 2008 Link to this post

    Hello Barry,

    Please refer to the following online resource . There you will find information for the RadAjax Client-Side API which should help you achieve the functionality you are searching for.

    Best regards,
    Maria Ilieva
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. LeBear
    LeBear avatar
    233 posts
    Member since:
    May 2006

    Posted 14 Mar 2008 Link to this post

    I don't see a direct way to do what I want to do.

    Let's say that I have a chat window and I want the chat output control to be updated with new posts as they come in, but I want to reduce network traffic as much as possible.

    I have a scenario where I would like to have the page (client-side) call a Web Service that asks if there are more posts available.  The Web Service would return a boolean indicating in there were more posts.  Then the client would make the call to update the chat output only when it was determined there were more posts. 

    Here's a simple look of what I want on the client.

    [Javascript]
    function getMorePosts(){
        var moreposts;
        moreposts = AjaxManager(WebServiceURL, IdOfLastKnownPost);
        if (moreposts){
            AjaxManager.AjaxRequestWithTarget(...);
        }
    }
    [/Javascript]

    The call to the web service would NOT be a call to the current page, but rather a simple web service that just looks to see if there are more posts after the last known post ID that was passed in.  If there are more, it will return a true, and if not, it will return a false.

    With this type of call, you would realize much less processing and network overhead by first checking with the server if there were more chat posts, and if there were, you would then make the actual call to update the chat activity control.

    There are other scenarios I would like to do this as well.  For example, a web page could check every now and again to see if a message were created for the user, and display a You Have Mail icon.

    Thanks.
  5. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 18 Mar 2008 Link to this post

    Hi Barry,

    Thank you for the detailed explanation.

    In order to achieve the required functionality, you could use the RadAjaxSeviceManager control. Please review the following help topic, which describes the control and its functionality. Also you could refer to these online examples, showing some implementation of the ServiceManager control.
    Please note that, if you decide to use the RadAjaxServiceManager and need to initiate synchronous Service Call,  you should set  the control  "PerformAsyncronousRequests" property to "false", as it is set to "true" by default.

    Let us know if the provided information is helpful.

    Best wishes,
    Maria Ilieva
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top