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)

Soap service request using Ajax (webworks)

Hi  Geeks,

 

I am new to webworks. Please let me know about soap service request using Ajax (webworks). Highly appreciable if anyone can send sample code. Thanks in advance.

 

Thanks & Regards:

amdgouse

Developer
Posts: 29
Registered: ‎09-11-2010
My Device: Bold 9700
My Carrier: AT&T

Re: Soap service request using Ajax (webworks)

I have an html page, I specified a div (Called divResult) that I want to display the xml sent back from the web service. My webservice address is stored in urlMyOffers, and it requires 2 parameters (uid and dscnt)

I place both funtions below in a javascript file (actions.js) that I reference in the html page (place this in the header: 

<

 

this is what I currently use inside actions.js, it works on OS5 and OS6 and Playbook:

script type="text/javascript" src="scripts/actions.js"></script>)

 

try {
 var params = 'uid=' + userid + '&dscnt=' + dsc;
        req = new XMLHttpRequest();
        req.onreadystatechange = handleOfferResponse;
        req.open('POST', urlMyOffers, true);
        req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
        req.setRequestHeader('Content-length', params.length);
        req.setRequestHeader('Connection', 'close');
        req.send(params);
    } catch (err) {
        alert("Error: " + err.message);
    }

function handleOfferResponse() {
    if ((req.readyState == 4) && (req.status == 200)) {
        var rslt = req.responseText;
        var displayDiv = document.getElementById('divResult');
        var myRegExp = new RegExp("&amp;", "g");
        var myResult = rslt.replace(myRegExp, "&");
        displayDiv.innerHTML = myResult;
    }
}

New Member
Posts: 1
Registered: ‎09-08-2013
My Device: BB7
My Carrier: Airtel

Re: Soap service request using Ajax (webworks)

Hi,

 

I am facing ajax issue on BB6/7. Here is my config and code. Please let me know what am i doing wrong.I am clueless as config and code looks good to me and works for all the platforms except BB7/6.

 

<?xml version="1.0" encoding="utf-8"?><widgetxmlns="http://www.w3.org/ns/widgets"xmlns:rim="http://www.blackberry.com/ns/widgets"version="2.0"rim:header="RIM-Widget: rim/widget"xml:lang="tr"><rim:navigationmode="focus"/><name>Countly Test</name><description>A sample application to demonstrate some features.</description><author>Artistanbul Developer Team</author><iconsrc="countly_logo_color.png"/><rim:orientationmode="auto"/><contentsrc="index.htm"></content><accessuri="*"subdomains="true"/><accessuri="http://www.casetracklive.com"subdomains="true"/><featureid="blackberry.identity"/><featureid="blackberry.identity.phone"/><featureid="blackberry.system"/><featureid="blackberry.app"/><featureid="blackberry.app.event"/></widget>


$.ajax({ type:'GET', url: "http://www.casetracklive.com", error: function(responseBody, status, response) { alert("error"); return false; }, success: function(data) { alert("success"); } });