Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Problem with jquery.ajax result - auto replaced chars and enclosed in XML - Why ???

Problem with jquery.ajax result - auto replaced chars and enclosed in XML - Why ???

Scheduled Pinned Locked Moved Web Development
javascripthtmlsysadminxmlhelp
9 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Stephan Pilz
    wrote on last edited by
    #1

    Hello, I've a jquery.ajax call. The result I set on server side is a string containing html fragment (some table rows). But on client side I get the result enclosed in

    <?xml version="1.0" encoding="utf-8"?>
    <string xmlns="http:...>
    

    Here comes my html fragment

    </string>
    

    In addition, in my html fragment each special html character like < or > are replace during the html codings < and > I don't understand why and I don't know, how I can get or extract my original result. Here is my short ajax function:

    function DoAjaxCall(bofg_refid, pc_refid)
    {
    $.ajax({
    type: "GET",
    url: "../Test.asmx/TestCall",
    data: "bofg_refid=" + bofg_refid + "&pc_refid=" + pc_refid,
    dataType: "text",
    success: function(html) {
    alert(html);
    }
    });

    }

                   \\\\\\|///
                 \\\\  - -  //
                  (  @ @  )
    

    +---------------oOOo-(_)-oOOo-----------------+
    | Stephan Pilz stephan.pilz@stephan-pilz.de |
    | www.stephan-pilz.de |
    | ICQ#: 127823481 |
    +-----------------------Oooo------------------+
    oooO ( )
    ( ) ) /
    \ ( (_/
    \_)

    D 1 Reply Last reply
    0
    • S Stephan Pilz

      Hello, I've a jquery.ajax call. The result I set on server side is a string containing html fragment (some table rows). But on client side I get the result enclosed in

      <?xml version="1.0" encoding="utf-8"?>
      <string xmlns="http:...>
      

      Here comes my html fragment

      </string>
      

      In addition, in my html fragment each special html character like < or > are replace during the html codings < and > I don't understand why and I don't know, how I can get or extract my original result. Here is my short ajax function:

      function DoAjaxCall(bofg_refid, pc_refid)
      {
      $.ajax({
      type: "GET",
      url: "../Test.asmx/TestCall",
      data: "bofg_refid=" + bofg_refid + "&pc_refid=" + pc_refid,
      dataType: "text",
      success: function(html) {
      alert(html);
      }
      });

      }

                     \\\\\\|///
                   \\\\  - -  //
                    (  @ @  )
      

      +---------------oOOo-(_)-oOOo-----------------+
      | Stephan Pilz stephan.pilz@stephan-pilz.de |
      | www.stephan-pilz.de |
      | ICQ#: 127823481 |
      +-----------------------Oooo------------------+
      oooO ( )
      ( ) ) /
      \ ( (_/
      \_)

      D Offline
      D Offline
      daveyerwin
      wrote on last edited by
      #2

      Maybe this is a good place to start ... http://api.jquery.com/[^]

      T 1 Reply Last reply
      0
      • D daveyerwin

        Maybe this is a good place to start ... http://api.jquery.com/[^]

        T Offline
        T Offline
        T M Gray
        wrote on last edited by
        #3

        What a nice way to say RTFM. :)

        S 1 Reply Last reply
        0
        • T T M Gray

          What a nice way to say RTFM. :)

          S Offline
          S Offline
          Stephan Pilz
          wrote on last edited by
          #4

          Thank you both for the very nice and very unhelpful message. I'm not a stupid programmer. I know the web ressources and online docus and I can and have read it. And if it would help, I would not post some questions here. All other guys with helpful informations: Please let me know. Thank you

                         \\\\\\|///
                       \\\\  - -  //
                        (  @ @  )
          

          +---------------oOOo-(_)-oOOo-----------------+
          | Stephan Pilz stephan.pilz@stephan-pilz.de |
          | www.stephan-pilz.de |
          | ICQ#: 127823481 |
          +-----------------------Oooo------------------+
          oooO ( )
          ( ) ) /
          \ ( (_/
          \_)

          D T 2 Replies Last reply
          0
          • S Stephan Pilz

            Thank you both for the very nice and very unhelpful message. I'm not a stupid programmer. I know the web ressources and online docus and I can and have read it. And if it would help, I would not post some questions here. All other guys with helpful informations: Please let me know. Thank you

                           \\\\\\|///
                         \\\\  - -  //
                          (  @ @  )
            

            +---------------oOOo-(_)-oOOo-----------------+
            | Stephan Pilz stephan.pilz@stephan-pilz.de |
            | www.stephan-pilz.de |
            | ICQ#: 127823481 |
            +-----------------------Oooo------------------+
            oooO ( )
            ( ) ) /
            \ ( (_/
            \_)

            D Offline
            D Offline
            daveyerwin
            wrote on last edited by
            #5

            Change your alert to this

            alert(html.split(">")[2].split("<")[0].replace("<","<").replace(">",">"))

            You may need to use &#60 instead of > also other characters may have been encoded which will als need replacing. Good Luck.

            1 Reply Last reply
            0
            • S Stephan Pilz

              Thank you both for the very nice and very unhelpful message. I'm not a stupid programmer. I know the web ressources and online docus and I can and have read it. And if it would help, I would not post some questions here. All other guys with helpful informations: Please let me know. Thank you

                             \\\\\\|///
                           \\\\  - -  //
                            (  @ @  )
              

              +---------------oOOo-(_)-oOOo-----------------+
              | Stephan Pilz stephan.pilz@stephan-pilz.de |
              | www.stephan-pilz.de |
              | ICQ#: 127823481 |
              +-----------------------Oooo------------------+
              oooO ( )
              ( ) ) /
              \ ( (_/
              \_)

              T Offline
              T Offline
              T M Gray
              wrote on last edited by
              #6

              You obviously didn't read the docs very well. http://api.jquery.com/jQuery.ajax/[^] Read the section on dataType and it will explain why your data comes back as XML. Look at the example of a success handler and you would have the code you need. Read the sentence after that example and it will point you to a better way to do it.

              S 1 Reply Last reply
              0
              • T T M Gray

                You obviously didn't read the docs very well. http://api.jquery.com/jQuery.ajax/[^] Read the section on dataType and it will explain why your data comes back as XML. Look at the example of a success handler and you would have the code you need. Read the sentence after that example and it will point you to a better way to do it.

                S Offline
                S Offline
                Stephan Pilz
                wrote on last edited by
                #7

                I've read the section dataType, before it post my first question. Did you have read my example code? You find the line, where I define the result datatype should be text (and not XML). And I get the same result, if I define the result datatype as HTML. This parameter did work by me and has no effect.

                               \\\\\\|///
                             \\\\  - -  //
                              (  @ @  )
                

                +---------------oOOo-(_)-oOOo-----------------+
                | Stephan Pilz stephan.pilz@stephan-pilz.de |
                | www.stephan-pilz.de |
                | ICQ#: 127823481 |
                +-----------------------Oooo------------------+
                oooO ( )
                ( ) ) /
                \ ( (_/
                \_)

                T 1 Reply Last reply
                0
                • S Stephan Pilz

                  I've read the section dataType, before it post my first question. Did you have read my example code? You find the line, where I define the result datatype should be text (and not XML). And I get the same result, if I define the result datatype as HTML. This parameter did work by me and has no effect.

                                 \\\\\\|///
                               \\\\  - -  //
                                (  @ @  )
                  

                  +---------------oOOo-(_)-oOOo-----------------+
                  | Stephan Pilz stephan.pilz@stephan-pilz.de |
                  | www.stephan-pilz.de |
                  | ICQ#: 127823481 |
                  +-----------------------Oooo------------------+
                  oooO ( )
                  ( ) ) /
                  \ ( (_/
                  \_)

                  T Offline
                  T Offline
                  T M Gray
                  wrote on last edited by
                  #8

                  Then the problem is obviously in your web service. And you still didn't impement the .html call as suggested in the docs.

                  D 1 Reply Last reply
                  0
                  • T T M Gray

                    Then the problem is obviously in your web service. And you still didn't impement the .html call as suggested in the docs.

                    D Offline
                    D Offline
                    daveyerwin
                    wrote on last edited by
                    #9

                    T M Gray wrote:

                    Then the problem is obviously in your web service. And you still didn't impement the .html call as suggested in the docs.

                    Your are probably right, if there is a 'problem' at all. If the service reurns 'text' formatted as xml then all is well. :)

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups