Forum Discussion

mayank's avatar
12 years ago
Solved

Lithium API to create a module to get the 3 most recent posts on other server

Lithium API to create a module to get the 3 most recent posts on other site

  • You will need to traverse the response object to find out the data you want

     

    Examples:

     

        success: function(data) {
    		var resp = data.response;
    		
    		alert("Response status is: " + resp.status);
    		alert("Response messages: " + resp.node_message_context.message.length);
    		alert("First message subject : " +resp.node_message_context.message[0].subject.$);
    		 
        }

     Of course the above are merely examples and should not be used in production - but it gives you an idea.

16 Replies

  • mayank's avatar
    mayank
    Ace
    12 years ago

    Code is almost ready just need to fetch post hyperlink ...but hyperlink is not coming in json format...Can you please help ....

  • mayank's avatar
    mayank
    Ace
    12 years ago

    $.ajax({
     url: 'url here,
        type: 'GET',
     dataType :'xml',
     async: false,
    crossDomain:true,
     success: function(data) {
     console.log(data.responseText);
     var resp = data.response;
     alert(resp);
     }
     });

     

    if i use another ajax call it show me error (In firebug)

     

    XML Parsing Error: no element found
    Location: moz-nullprincipal:{8f379bf5-ac8f-4cf9-b336-2875e210a396}
    Line Number 1, Column 1:

     

    Please help

  • mayank's avatar
    mayank
    Ace
    12 years ago

    It works thanks a ton again..you are genious....can you please tell why it is not printing username :

     

    alert(resp.node_message_context.message[i].login.$);

     

     

     

  • mayank's avatar
    mayank
    Ace
    12 years ago

    alert(resp.node_message_context.message[i].author.login.$);

     

    its working,...