Teach Me How to use JSONP to get A Simple Working Mobile App (Written using Cordova, JQuery & Express Node.js) to work around the Same-Origin Policy

Zrušen Zveřejněno před 6 lety K zaplacení v momentě doručení
Zrušen

Hi. I am Philip Lam and I have just started learning mobile app development.

I am trying to develop a basic mobile app which can get and post data to a server.

I have managed to get a very simple mobile app working.

This mobile app is based on a web application that counts the number of times the word "awesome" appears in Twitter messages. It was taught in the book entitled, "Learning Web App Development" by Semmy Purewal. In the first edition of that book, I got to page 203 and then adapted the web application using the Cordova framework into a mobile app.

Briefly, the mobile app consists of a front end ([login to view URL]) which says, "Some Data From Twitter", and "awesome:" followed by the number of mentions. This number increases over time because the number tracks the cumulative number of times the word "awesome" is mentioned in Twitter messages as more and more messages are generated.

The back end is an Express Node.js server ([login to view URL]) which tracks the ever increasing number of times the word "awesome" is mentioned. The data is sent between the front end and the back end by way of jQuery JSON GETs and POSTs.

So far, I have successfully gotten the server side to launch and work. The server also correctly displays the number of times the word "awesome" appears in its console.log. Furthermore, the browser on my PC is also able to detect the server's performance. All this is working fine.

The problem is that when the mobile app is launched into the Android emulation, it does not show anything from the server. On the other hand, the browser on the Android emulation (when directed to [login to view URL]) does show the correct response from the server. (BTW, [login to view URL] is the loopback IP address for the Android emulation to access the server which is on the same PC as the emulation whereas 3000 is the port where the server is listening.)

I strongly suspect that the problem lies with the Same-Policy Origin and if I am correct, I wish to use JSONP to overcome the problem. Please teach me how to debug the code so that the mobile app can detect and "see" what the browser on my PC and the browser on the Android emulation are able to detect and "see".

The code "works" perfectly in the sense that the server is clearly working (since my PC browser and also the Android emulation browser can both "see" and track the server). The problem is that the mobile app itself does not detect or "see" the server's responses at all.

There is a limit to the number of words I can type here so I have put all the code into a word document and uploaded it for your reference.

Thanks and I look forward to hearing from you.

Regards,

Philip Lam

App Design Vývojář aplikací Express JS jQuery / Prototype Mobile App Development

Identifikační číslo projektu: #15351676

O projektu

2 nabídek Projekt na dálku Aktivní před 6 lety

2 Freelnceři na váš projekt zveřejňují nabídky v průměru $8/hod.

kasidev

Hello, my name is Joel. I am a software developer with a focus on mobile (Android Native and hybrid) and Web Development(PHP and c#) using frameworks like Laravel or CodeIgniter. I have over 5 years of experience

$10 SGD / hodina
(0 Recenzí)
0.0