Welcome to the Official BlackBerry® Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Web and WebWorks Development

Reply
Developer
jmace
Posts: 482
Registered: 10-24-2008
My Carrier: AT&T

Re: xmlHttpRequest response containing HTML

as an FYI https://www.blackberry.com/jira/browse/WEBAPI-45
_________________________________________
www.jasonmace.com/blackberry
Please use plain text.
New Developer
nbelcher
Posts: 8
Registered: 02-15-2009

Re: xmlHttpRequest response containing HTML

[ Edited ]

I'm a noob. Anyone get this working? I'm getting same result. I get string value back from asmx service but when I assign the DIV the value it displays exactly what was sent back and not HTML formatted.

 

Service:

<WebMethod()> _

Public Function GetStuff() As String

 Return "<div>This is some HTML <font size=10>HELP ME</font></div>"

 

End Function

 

Script:

 

function getstuff() {

...

xmlHttp.open('GET', url, true);

xmlHttp.onreadystatechange = function() {

...

var result = xmlHttp.responseXML;

document.getElementById("stuff").innerHTML = result;

}

 

The BB div tag displays the exact HTML string as returned from the service and not formatted as you would expect. I've tried pulling the node value but I get null. I've tried responseTEXT with the same result.

 

I'm missing something stupid I know it....

 

 

Please use plain text.
Developer
jmace
Posts: 482
Registered: 10-24-2008
My Carrier: AT&T

Re: xmlHttpRequest response containing HTML

 

xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4) 
{
var contentElement = document.getElementById("MidDiv);
//Temporary fix until RIM works out issue with responseX
};
... xmlHttp.onreadystatechange = function() {  if (xmlHttp.readyState == 4)  { var contentElement = document.getElementById("MidDiv"); //Temporary fix contentElement.innerHTML = processUpdate(xmlHttp.responseText);   blackberry.focus.setFocus('Select1'); alert("station update received"); } }; ...
//Temporary method to parse responseText
function processUpdate(toProcess) {
   toProcess = toProcess.replace(/&lt;/g,"<").replace(/&gt;/g,">");
   var seperatedString = toProcess.split("~");
   // save the individual data segments
   var myAnswer = seperatedString[2];
   saveNewDataUpdate(seperatedString);
   return myAnswer;
}

 

Here is some of my code. 

 

I'm passing the entire responseText to processUpdate(). 

 

Then I'm replacing the placeholders for the  "<" and ">". In your web service, instead of < and > , you will need to use &lt;/g   and &gt;/g .

 

I'm then updating my div with the content from array position 2 while saving the rest of the array into a sqlite database.

 

_________________________________________
www.jasonmace.com/blackberry
Please use plain text.
Developer
jmace
Posts: 482
Registered: 10-24-2008
My Carrier: AT&T

Re: xmlHttpRequest response containing HTML

Sorry, I mispoke in the above post.

 

On my web service side, I build the html string accordingly

 

i.e.    string test = "<div> .... </div>";

 

Then, on the device side I use the methods from the post above. I'm guessing the most important part will be the .replace(....) line in my processUpdate function.

_________________________________________
www.jasonmace.com/blackberry
Please use plain text.