Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Contributor
Posts: 25
Registered: ‎03-08-2011
My Device: storm, bold, torch & Blackberry Tablet (Playbook)
My Carrier: storm, bold, torch & Blackberry Tablet (Playbook)

Can anyone send me Sample XMLHttpRequest webworks app (code). please help me....!

hi   Geeks,

 

Can anyone send me  Sample XMLHttpRequest webworks app (code). please help me....!  Thanks in advance.

 

Thanks & Regards:

amdgouse

New Contributor
Posts: 7
Registered: ‎05-24-2011
My Device: Bold 9700
My Carrier: Developer

Re: Can anyone send me Sample XMLHttpRequest webworks app (code). please help me....!

for your guidance try this

// JScript File
var xmlHttpReq = null;
var WS = "http://YourServer/testBBWebService/";
function getNewHTTPObject() {
    var xmlhttp;
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
        try {
            xmlhttp = new XMLHttpRequest();
        }
        catch (e) {
            xmlhttp = false;
        }
    }
    return xmlhttp;
}

function get3IT() {

    xmlHttpReq = getNewHTTPObject();
    alert("begin get3IT " + Date());
    if (xmlHttpReq == false) {
        alert("create XMLHttpRequest Ojbect error");
        return;
    }

    var url = WS + "YourWebService.asmx/GetDataTest";
    var data = "?name=" + "JOHN" + "&surname=" + "RAMBO";

    alert("before send:" + url);
    xmlHttpReq.open('GET', url, true);
    xmlHttpReq.onreadystatechange = showData;
    xmlHttpReq.send(null);
} //end function
function showData() {
    var result = "";
    var show = document.getElementById("show");
    var m = ".";
    if (xmlHttpReq.readyState == 4) {
        /** show responseText
        result = xmlHttpReq.responseText; 
        show.innerHTML = result;
        **/
        /** show responseXML ***/
        result = xmlHttpReq.responseXML;
        result = result.getElementsByTagName("string")[0].childNodes[0].nodeValue;
        var dsp = "";
        //Convert to JSON object
        var myJsonObj = jsonParse(result);
       
        for (var k in myJsonObj) {
            // alerts x=Hello, World!  and  y=1,2,3
            dsp = dsp + ('Emp. Id. = ' + myJsonObj[k].empid + '<br />');
        }
        show.innerHTML = dsp;
    }
}//end

Highlighted
Contributor
Posts: 25
Registered: ‎03-08-2011
My Device: storm, bold, torch & Blackberry Tablet (Playbook)
My Carrier: storm, bold, torch & Blackberry Tablet (Playbook)

Re: Can anyone send me Sample XMLHttpRequest webworks app (code). please help me....!

Thanks in advance....!

 

I Done Soap web service request using 1.URL 2.Username/Password 3.Requested XML. I Done this using j2me api's, blackberry api's & java api's for Blackberry Smartphones. But i don't know how to make Soap web service request [ URL, username/password, Requested XML ] using webworks api's & Ajax. Please help me to get sample code for making an Soap web service request using 1.URL, 2.username/password, 3.Requested XML by using webworks api's & Ajax.