Problem with jquery.ajax result - auto replaced chars and enclosed in XML - Why ???
-
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 ( )
( ) ) /
\ ( (_/
\_) -
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 ( )
( ) ) /
\ ( (_/
\_)Maybe this is a good place to start ... http://api.jquery.com/[^]
-
Maybe this is a good place to start ... http://api.jquery.com/[^]
-
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 ( )
( ) ) /
\ ( (_/
\_) -
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 ( )
( ) ) /
\ ( (_/
\_)Change your alert to this
alert(html.split(">")[2].split("<")[0].replace("<","<").replace(">",">"))
You may need to use < instead of > also other characters may have been encoded which will als need replacing. Good Luck.
-
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 ( )
( ) ) /
\ ( (_/
\_)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.
-
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.
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 ( )
( ) ) /
\ ( (_/
\_) -
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 ( )
( ) ) /
\ ( (_/
\_) -
Then the problem is obviously in your web service. And you still didn't impement the .html call as suggested in the docs.
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. :)