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
Developer
Posts: 27
Registered: ‎05-12-2011
My Device: Playbook 2.0, Dev Alpha A
My Carrier: Waiting for BB 10

Dev Alpha deployed app: AJAX response problem

My app works properly with PC browsers and the Dev Alpha AIR browser and deploys properly up as far as the AJAX response, which returns server source code.

 

I added 

    ajax.setRequestHeader("Content-Type", "text/plain");   

just before   

    ajax.send("");

 

This didn't help.

 

BTW is there any workaround for the missing  blackberry.system.hasDataCoverage() ??

BlackBerry Development Advisor
Posts: 762
Registered: ‎10-01-2009
My Device: All
My Carrier: N/A

Re: Dev Alpha deployed app: AJAX response problem

Hello,

 

Would you mind posting the entire ajax request, and what you're expecting it to return to you upon success?

Developer
Posts: 27
Registered: ‎05-12-2011
My Device: Playbook 2.0, Dev Alpha A
My Carrier: Waiting for BB 10

Re: Dev Alpha deployed app: AJAX response problem

In my app ---

        ajax = new XMLHttpRequest();
        ajax.onreadystatechange = pay2;
        ajax.open('GET','join.php?u='+Fusr, true);
        document.getElementById("but").innerHTML = 'Processing...';
        ajax.setRequestHeader("Content-Type", "text/plain");
        ajax.send("");  

 

at the server ---    
      echo "Sorry, this name is not available.";
or

       echo $row["mDate"];
or

       echo "Sorry, could not insert this name.";


Developer
Posts: 27
Registered: ‎05-12-2011
My Device: Playbook 2.0, Dev Alpha A
My Carrier: Waiting for BB 10

Re: Dev Alpha deployed app: AJAX response problem

and of course ---

function pay2() {
if ((ajax.readyState == 4) && (ajax.status == 200)) {
alert(ajax.responseText);

etc., which somehow displays the source contents of join.php
Retired
Posts: 37
Registered: ‎01-08-2010
My Device: Various
My Carrier: Rogers

Re: Dev Alpha deployed app: AJAX response problem

Connection information is now available here:

https://developer.blackberry.com/html5/apis/blackberry.connection.html

Developer
Posts: 27
Registered: ‎05-12-2011
My Device: Playbook 2.0, Dev Alpha A
My Carrier: Waiting for BB 10

Re: Dev Alpha deployed app: AJAX response problem

Thanks cdelcol, that link looks very helpful. 

 

I'll hafta get a 24" monitor as that's yet another RIM page that needs View-Page-Source to understand.

Developer
Posts: 27
Registered: ‎05-12-2011
My Device: Playbook 2.0, Dev Alpha A
My Carrier: Waiting for BB 10

Re: Dev Alpha deployed app: AJAX response problem

I tried a different approach and after working around a few Gotchas it seems to work OK. ---

 

document.getElementsByTagName('head')[0].appendChild(script);

 

I see my way clear now to submitting my first Dev Alpha app!

I'll worry about adding 'payment' and 'BBM' later.

 

Thanks for your help everybody.

Developer
Posts: 322
Registered: ‎08-06-2012
My Device: Dev Alpha / Playbook / Curve 9300

Re: Dev Alpha deployed app: AJAX response problem

I'm assuming that in your ajax call the GET, "join.php" is actually a full url?

 

Otherwise it would be trying to find that page locally on the device which wouldn't work (AFAIK you can't run PHP on blackberry).  It may be working now in your test folder on your machine.

If it helped you, click like. Smiley Happy
Developer
Posts: 27
Registered: ‎05-12-2011
My Device: Playbook 2.0, Dev Alpha A
My Carrier: Waiting for BB 10

Re: Dev Alpha deployed app: AJAX response problem

 

My "GET - join.php" actually updated the server correctly but Dev Alpha saw only the join.php source code .

I think there must be a header problem from Dev Alpha to host server.  I've never had to bother with headers before and know little about them.

 

When I ran  join.php?u=kook  by itself it output correct text.

Also, similar AJAX calls on Playbook worked correctly without a full URL and with no added header info.

 

Thanks for the reply.

Developer
Posts: 322
Registered: ‎08-06-2012
My Device: Dev Alpha / Playbook / Curve 9300

Re: Dev Alpha deployed app: AJAX response problem

Of the 200 million plus websites, how does your app know where join.php is?

 

You say: 


eketahuna wrote:

 

When I ran  join.php?u=kook  by itself it output correct text.

Also, similar AJAX calls on Playbook worked correctly without a full URL and with no added header info.

 


Where were you running that from?  On the playbook?  Is this a webworks app compiled and running like native or are you browsing to a web page and running the app there?

If it helped you, click like. Smiley Happy