1. #1
    Sencha User mes-x's Avatar
    Join Date
    Mar 2010
    Posts
    27
    Vote Rating
    1
    mes-x is on a distinguished road

      0  

    Default Answered: Parsing AJAX Response HTML

    Answered: Parsing AJAX Response HTML


    Hello everyone!

    Is it in ExtJS possible to parse an HTML AJAX Response?

    I'm downloading some HTML pages with Ext.Ajax.request(). The pages contain full html with doctype head and body elements. Now i want to parse it in any way (reading some header tags, modify some body stuff, ...).

    As i know, jQuery could do that by using $(responseVariable.responseText) but can do ExtJS something similar?


    thank you very much for all your respones and best regards
    Manuel

  2. I have used a scenario where I needed to display a loadmask while an iframe loads. It is possible to inject an onload="" event into the element itself. So, in theory, you could create a custom function to give you back data (ie: the body of the DOM) when the iframe finishes loading.

  3. #2
    Sencha - Community Support Team friend's Avatar
    Join Date
    Apr 2011
    Posts
    895
    Answers
    106
    Vote Rating
    27
    friend has a spectacular aura about friend has a spectacular aura about

      0  

    Default


    Here's a code sample from the API docs for Ext.Ajax.request(). Note that you can get at the response and do anything you want with it:

    Code:
    Ext.Ajax.request({
        url: 'page.php',
        params: {
            id: 1
        },
        success: function(response){
            var text = response.responseText;
            // process server response here
        }
    });

  4. #3
    Sencha User mes-x's Avatar
    Join Date
    Mar 2010
    Posts
    27
    Vote Rating
    1
    mes-x is on a distinguished road

      0  

    Default


    Thank you very much for your quick response!

    The question is about processing the server response which is a full html page. I want to parse the html (read it (for example Ext.Element.getAttribute()), manipulate it (example Ext.Element.createChild())) and after that maybe (depending on read) write it to the DOM.

    The reason why not just creating a hidden <div> and adding the responseText there is simply because of the <head>. I need to also parse all <meta> stuff or <title> tags which are not placed inside the DOM. Or <script> tags would execute immediately but i just want to read the src attribute from it, ..., ..., ..., ...

    best regards!
    Manuel

  5. #4
    Sencha - Community Support Team friend's Avatar
    Join Date
    Apr 2011
    Posts
    895
    Answers
    106
    Vote Rating
    27
    friend has a spectacular aura about friend has a spectacular aura about

      0  

    Default


    The response is basically just a big String and there are no DOM objects associated with it. You'll have to do the work of parsing/creating DOM objects (possibly via Ext.DomHelper?).

    You might be better off rendering the HTML response to a panel that's hidden or offscreen, manipulating the DOM appropriately, then showing the panel.

  6. #5
    Sencha Premium Member
    Join Date
    Apr 2011
    Posts
    101
    Answers
    8
    Vote Rating
    3
    sskow200 is on a distinguished road

      0  

    Default iFrame?

    iFrame?


    Couldn't you just load the page into an iframe and manipulate it there?

  7. #6
    Sencha - Community Support Team friend's Avatar
    Join Date
    Apr 2011
    Posts
    895
    Answers
    106
    Vote Rating
    27
    friend has a spectacular aura about friend has a spectacular aura about

      0  

    Default


    I think the browser prevents you from being able to manipulate DOM and/or perform scripting on the contents of an iframe.

  8. #7
    Sencha Premium Member
    Join Date
    Apr 2011
    Posts
    101
    Answers
    8
    Vote Rating
    3
    sskow200 is on a distinguished road

      0  

    Default


    I have used a scenario where I needed to display a loadmask while an iframe loads. It is possible to inject an onload="" event into the element itself. So, in theory, you could create a custom function to give you back data (ie: the body of the DOM) when the iframe finishes loading.

  9. #8
    Sencha User mes-x's Avatar
    Join Date
    Mar 2010
    Posts
    27
    Vote Rating
    1
    mes-x is on a distinguished road

      0  

    Default


    Ok, so there is no elegant way of parsing the responseText as HTML?
    I think, i'll use jQuery with ExtJS.

    thx for all your help!

Thread Participants: 2

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi