Loading ...
Sorry, an error occurred while loading the content.

YUI connection manager

Expand Messages
  • atif ali
    Hi everyone, I am new bie on YUI. I am using connection manager for ajax call. I want to return an array from back end or server script. But I couldn t get
    Message 1 of 6 , Feb 13, 2007
    • 0 Attachment
      Hi everyone,
      I am new bie on YUI. I am using connection manager for ajax call. I
      want to return an array from back end or server script. But I couldn't
      get array and print_r() couldn't fulfill my requirements. if someone
      knows better please reply.

      Cheers!
    • atif ali
      I just need other options when I am getting results from my server script instead of printing or echoing. I want to return some variable and work on those
      Message 2 of 6 , Feb 13, 2007
      • 0 Attachment
        I just need other options when I am getting results from my server
        script instead of printing or echoing. I want to return some variable
        and work on those variables. Is this possible
      • Ivan Ivankovic
        You can return whole JavaScript expression like: var i = 4; from server and then use eval(o.responseText); in your response handler function where response
        Message 3 of 6 , Feb 14, 2007
        • 0 Attachment
          You can return whole JavaScript expression like:
          var i = 4;
          from server and then use
          eval(o.responseText ); in your response handler function where response text equals "var i = 4".
          After that variable "i" can be used as any other.

          Of course variable "i" can be array if you like, or JSON expression in general. I used this approach for returning quite complex data structures from server.

          Grettengs,
          Ivanko

          On 2/14/07, atif ali <aatifali21@...> wrote:

          I just need other options when I am getting results from my server
          script instead of printing or echoing. I want to return some variable
          and work on those variables. Is this possible




          --
          Pozdrav,
          Ivanko
        • atif ali
          Thanks Ivanko, [;)] I have completed my requirements now. This is relatively very simple example and true use of connection manager with treeview. Hope
          Message 4 of 6 , Feb 14, 2007
          • 0 Attachment
            Thanks Ivanko,;)

            I have completed my requirements now. This is relatively very simple example and true use of connection manager with treeview. Hope somebody will need this

            Well I am not a good documenter but  sill this code will help.  :)

            <----------------------------------    Code  ----------------------------->


            <--- Server code will come here / Backend --->

            <?php
            if(isset($_GET['ajax'])){
                if($_GET['id']==1)
                {
                $a=1;
                $a.=",2";
                $a.=",3";
                $a.=",4";
                $a.=",5";
                $a.=",6";
                $a.=",7";
                }
            print_r($a);
            }
            ?>

            <-----End of  Sever code -->

            <----Javascript and use of YUI library ------->

            <script type="text/javascript">
            var tree;
            function treeInit() {
                    tree = new YAHOO.widget.TreeView("treeDiv1");
                    tree.setDynamicLoad(loadNodeData);
                    var tmpNode;
                    for (var i = 0; i < 3; i++) {
                    var name = "label-"+i;
                    var myobj = { label: name,id:i };
                    tmpNode = new YAHOO.widget.TextNode(myobj, tree.getRoot(),  false);
                    }
                    tree.draw();
            }
            var handleSuccess = function(o){
                    //console.log(o);
            //        alert(o.responseText);
                    var name = new Array();
                    name = o.responseText.split(',');;
            //        alert(name);
                    for(i=0;i<name.length;i++){
                        var tmpNode = new YAHOO.widget.TextNode(name[i], o.argument.node, false);
                    }
                    o.argument.fnLoadComplete();
                    console.log("fnLoadCompleted");
            }

            var handleFailure = function(o){
                    alert("async request failed");
            };

            var callback =
            {
                success:handleSuccess,
                failure:handleFailure,
                argument:{}
            };

            function loadNodeData(node, fnLoadComplete) {
                    callback.argument.fnLoadComplete = fnLoadComplete;
                    callback.argument.node = node;
                    var url = 'connectiontree.php?ajax=true&id= '+ node.data.id;
                    var request = YAHOO.util.Connect.asyncRequest('get',url,callback);
            }

            YAHOO.util.Event.addListener(window, "load", treeInit);

            </script>


            <------------------End of Script-------------------------------->


            <body>
            <div id="treeDiv1"></div>
            </body>

            <--------End of  Code-------------------------------------------------------->

            Cheers !


          • anilnamde
            Generally we use the connection manager to invoke the Ajax request and send the key value pairs using the request. However how can we form the Ajax request if
            Message 5 of 6 , Jan 6, 2010
            • 0 Attachment
              Generally we use the connection manager to invoke the Ajax request and send the key value pairs using the request.
              However how can we form the Ajax request if we would like to pass the JSON or XML data using the request body? What all other possibilities are there ? Or we are just restricted to send only key=value pair using the Connection Manager?
            • Satyam
              For JSON, see: http://www.satyam.com.ar/yui/2.5.0/JSONsend.php ... For JSON, see: http://www.satyam.com.ar/yui/2.5.0/JSONsend.php El 07/01/2010 8:31, anilnamde
              Message 6 of 6 , Jan 7, 2010
              • 0 Attachment
                For JSON, see:

                http://www.satyam.com.ar/yui/2.5.0/JSONsend.php



                El 07/01/2010 8:31, anilnamde escribió:
                Generally we use the connection manager to invoke the Ajax request and send the key value pairs using the request.
                However how can we form the Ajax request if we would like to pass the JSON or XML data using the request body? What all other possibilities are there ? Or we are just restricted to send only key=value pair using the Connection Manager?
                
                
                
                ------------------------------------
                
                Yahoo! Groups Links
                
                <*> To visit your group on the web, go to:
                    http://groups.yahoo.com/group/ydn-javascript/
                
                <*> Your email settings:
                    Individual Email | Traditional
                
                <*> To change settings online go to:
                    http://groups.yahoo.com/group/ydn-javascript/join
                    (Yahoo! ID required)
                
                <*> To change settings via email:
                    ydn-javascript-digest@yahoogroups.com 
                    ydn-javascript-fullfeatured@yahoogroups.com
                
                <*> To unsubscribe from this group, send an email to:
                    ydn-javascript-unsubscribe@yahoogroups.com
                
                <*> Your use of Yahoo! Groups is subject to:
                    http://docs.yahoo.com/info/terms/
                  
                No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.725 / Virus Database: 270.14.127/2603 - Release Date: 01/06/10 08:35:00
              Your message has been successfully submitted and would be delivered to recipients shortly.