facebook

xml retrieval

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #349258 Reply

    idkpmiller
    Member

    Hi,
    I am using mobione v2.6.2
    The application should be provided with a URL and when it receives XML display this in a textarea. The app should support sites that have basic auth.

    I have put together some code that deals with a standard html page with basic auth and the success trigger fires for this use case; however if I point the app to a url that has xml content in the response It does not fire the success event. looking at the transactions on wireshark I can see that the 200 response is received and does have xml message content.
    Are you able to help me?

    The login function I am using:

    
    function Login() {
        var url = $('#m1-Poster-url').val();
        var user = $('#m1-Poster-userid').val();
            var pass = $('#m1-Poster-pass').val();
        
        $.ajax({
            type: "GET",
            url: url,
            dataType: "xml",
            timeout: 8000, 
            username: user,
            password: pass,
    
            success: function (xml, textStatus, response) {
                alert( "Response: " + textStatus); 
            }
        });
        
        updateTextArea('Login Function Complete');
    }
    

    Thanks

    Paul

    #349271 Reply

    Code_A
    Member

    Here is a working example that is similar to what you are trying to do. You should be able to quickly modify it to work with your situation to see if you can get the communication going.

    Attachments:
    You must be logged in to view attached files.
    #349273 Reply

    support-michael
    Keymaster

    I usually fire up the chrome dev tools to get deeper insight into such errors. Also I would include an error handler.

    Here is a working example that uses the done() promise in place of the success callback. The success callback has been deprecated for a while now. The url will return the elevation of dallas, tx.

    
    $.ajax({url: "http://www.earthtools.org/height/32.7758/-96.7967"})
      .done( function(data, status) { alert("success: " + data); } ) 
      .fail( function(jqXHR, status) { alert("fail: " + status); } )
    
    #349313 Reply

    idkpmiller
    Member

    Thanks you both for your response, the example from Code A was of particular help.
    However using the example and the code attached to the SUBMIT button a small change to
    add the ajax parameters for username/password response seems to break things; here is the slightly modified code

                
    //THIS WORKS FOR TEXT!!!
                webReq = jQuery.ajax({
                    url: $("#m1-XSI-urlEntry").val(),
                    username: "myusername",
                    password: "secret",
                    type: "GET",
                    dataType : "html",    
                    contentType : "text/plain; charset=utf-8"
                });        // END of JQuery Ajax
    

    Is this a bug with mobione?
    Thanks
    Paul

    #349316 Reply

    Code_A
    Member

    Try passing your data like this instead:

             webReq = jQuery.ajax({
                url: $("#m1-XSI-urlEntry").val(),
                username: "myusername",
                password: "secret",
                data     : { username : "myusername", password : "secret" },
                type: "GET",
                dataType : "xml",   
                contentType : "text/plain; charset=utf-8",
                async : false
             });      // END of JQuery Ajax
Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: xml retrieval

You must be logged in to post in the forum log in