Android Question I have PHP - I am using Javascript "document.write" which give me JSON after 5 seconds - app json error

petr4ppc

Well-Known Member
Licensed User
Longtime User
Dear friends,

normally I can receive and work with JSON ( I get [{"countactive":"2"}] from php and I can work with that in B4A),

but now I am trying to do new task:

I have PHP with javascript which give me JSON string BUT I get it after +-3 second ..... (after I start simple HTTP task via my browser)
but
My app crashed, because when I started the request in B4A, then after some miliseconds I see in LOGs only "html" code of my PHP site....and not JSON output in format [{"countactive":"2"}] which this site can generate after 3-5 second

and it is clear that this code crashed (I understand):
Dim myjson As Map
myjson=mx

Please how can I wait for this json string with my B4A app? What is better way - how to solve this task?
How can I disable reading "html" content of my php site and how can I wait 3-5second only for described JSON (text)?


Is it possible?
Best regards
p4ppc
 
Last edited:
Solution
The problem is not with the waiting. The problem is that the server returns JavaScript that you need to execute. See my previous answer.

Erel

B4X founder
Staff member
Licensed User
Longtime User
Is it possible?
Not exactly.

Based on your description the server returns a html page with JavaScript. The browser executes the JavaScript and something happens. Maybe it creates another request with the url that you are looking for or maybe it does something else. Use the browser development tools to understand what happens.
 
Upvote 0

petr4ppc

Well-Known Member
Licensed User
Longtime User
Dear Erel, friends,

yes, everything is as you wrote.

For certain I must ask:
Is here some possibility how to work with webpage such this with B4A?
So - I get result (plain text - not JSON) via webpage after 3-5second.
Can I do some http request, wait 3-5 seconds and then work with this result (text) using B4A?

Best regards
p4ppc
 
Upvote 0

hung

Active Member
Licensed User
Longtime User
Dear Erel, friends,

yes, everything is as you wrote.

For certain I must ask:
Is here some possibility how to work with webpage such this with B4A?
So - I get result (plain text - not JSON) via webpage after 3-5second.
Can I do some http request, wait 3-5 seconds and then work with this result (text) using B4A?

Best regards
p4ppc
You may do debug on the return message. Instead of putting into map, put into a string and show on screen. Perhaps your api returned an error message in html format.
 
Upvote 0
Top