Novice question: PhoneGap and AJAX

I having difficulty getting even basic AJAX to work with PhoneGap developer and wanted to see if someone could help me.

I'm currently testing using the W3Schools PHP AJAX sample, so I can sort of "accumulation" my PhoneGap/AJAX capabilities to develop the functionality of user login for a mobile application that I've been responsible for creating. But, as someone who is not a programmer by any means (and that tends to confuse networking questions... don't even start on proxies!), I'm baffled to even try to get the W3Schools sample to work.

The sample, which can be found here (AJAX PHP), is as follows. (For those who, like me, also not by spirit program and who think better visually, the sample has a text box where if you type the first few letters of the name of a person, it will try to find names starting with those letters in the database file that it invites. It displays the real-time results of what it finds in the area of text that the user types).

HTML/JavaScript/AJAX:

< html>
< head >
< script >
function showHint (str) {}
If (str.length == 0) {}
document.getElementById("txtHint").innerHTML = "";
return;
} else {}
var XMLHTTP = new XMLHttpRequest();
XMLHTTP.onreadystatechange = function() {}
If (xmlhttp.readyState == 4 & & xmlhttp.status == 200) {}
document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
}
};
XMLHTTP. Open ("GET", "gethint.php? q =" + str, true);
XMLHTTP. Send();
}
}
< / script >
< Sandwiched >
< body >

< p > < b > start typing a name into the field below:<b/b/b><p/p/p>
< form >
First name: <input type ='text' onkeyup ="showHint (this.value)">
< /Form >
< p > Suggestions: <span id ="txtHint"></ span><p/p/p>
< /Body >
</html >

PHP file:

<? PHP

Table with the names

$a [] = 'Anna ';

$a [] = "Britain";

$a [] = "Cinderella."

$a [] = "Diana."

$a [] = 'Eva ';

$a [] = 'Fiona ';

$a [] = "Gunda";

$a [] = "Hege";

$a [] = 'inga ';

$a [] = 'Johanna ';

$a [] = "Kitty";

$a [] = "Linda."

$a [] = 'Nina ';

$a [] = "Ophelia."

$a [] = "Petunia".

$a [] = 'Amanda ';

$a [] = 'Raquel ';

$a [] = "Cindy."

$a [] = 'Doris ';

$a [] = "Eve."

$a [] = "Evita";

$a [] = "Sunniva.

$a [] = "Tove";

$a [] = "Unni"

$a [] = "Purple";

$a [] = "Liza."

$a [] = 'Elizabeth ';

$a [] = "Ellen."

$a [] = 'Michael ';

$a [] = 'Vicky ';

get the q of URL parameter

$q = $_REQUEST ['q'];

$hint = "";

Search all advice table if $q is different from «»

if ($q !== "") {

$q = strtolower ($q);

$len = strlen ($q);

{foreach ($a as $name)

If (stristr ($q, substr ($name, 0, $len))) {}

If ($hint = "") {}

$hint = $name;

} else {}

$hint. = ", $name";

}

}

}

}

Never out "no suggestion" If no reference has been found or out of correct values

echo $hint = ""? "no suggestion": $hint; "

? >

Test the HTML file in my browser, everything works perfectly.

However, do the above in a project PhoneGap and test it on my Android phone, the possibility of dismissal of name does not work. And of course thanks to the AJAX control is not running.

Anyone know how I can fix this problem? I've already put the following in my config.xml file and nothing changed:

< access origin = "" * "subdomains ="true"/ >"

Thanks in advance.

You pouvez host PHP files locally on your dev machine, although I suggest the implementation of a virtual test machine so that you don't have to muck about with the main configuration of your dev machine.  In addition, if your virtual machine is a linux VM, which will give practice you when you put something in place elsewhere, because chances are good that you it would be deployed to a linux machine in the cloud. There are many devices out there who have a LAMP stack put in place of the out-of-the-box (LLinux Apache, MySQL, PHP) - for example, https://www.turnkeylinux.org/lampstack.

As long as your mobile device is on the same network as your development computer (/VM), you can connect with a local IP address (like 192.168. *). You must also be able to connect using your local hostname (such as your - macbook.local) or something similar. It depends on how you configure when you create a virtual machine, but virtual machines live generally on your network with a different IP address on your dev machine. (This behavior, however, is usually the default.)

You can also use environments such as Cloud9 and similar services to test the code like this. They are not suitable for production code, but you can run a PHP script (or node, etc.) and essentially have an external server underpowered with little or no effort on your part.

Side note: personally, to avoid 'localhost' even during the test, because 'localhost' can mean several things depending on what you are testing for:

  • essay on a physical device: made localhost refers to the device
  • testing on an emulator: done localhost refers to the emulator
  • tests on iOS Simulator: done localhost refers to the machine of dev
  • test in a browser on your dev machine: locahost refers to the machine of dev

If you use host names/IP addresses, there is no ambiguity, so why I suggest to use it.

Finally, don't forget to check that your firewall accepts external requests on port, that you intend to use.

Tags: PhoneGap

Similar Questions

  • Novice question - shortening and then recording the smallest Clip under a new name

    Brand new - is there an easy way to take a video file, I imported and set a new starting point and the end point, and then save it under a new name? The subject of my video requires a camera to film for a few minutes, but I only get action for 10 seconds.  I want to quickly preview the throughout the video and make shorter copies and then begin to work with them on the timeline.  So, is there an easy way to shorten a MP4 for example and then save it in the shorter size before you begin to import in the chronology and the PP?

    Thank you

    If you have a lot of work like this, where you need subitems in the sections named for specific purposes, you might consider using prelude, as it is designed expressly for this workflow. You can view clips, starting points, then tell him what you want to call and where to put it... and it will transcode your 'new' clip anywhere you want. There are a few programs out there 'in the wild' that can supposedly some formats and lop off just before & after an area chosen without re-encoding, but I don't know anything about this other that they exist.

    Neil

  • I've forgotten the answer to my security questions. And now it's blok

    I've forgotten the answer to my security question. And now I can go in real life.

    Note that there are links in this article, where you can contact Apple > If you forgot your Apple ID - Apple Support security questions answered

  • I forgot my secret question, answer and the second email but I have the password of my ID Apple and my phone number. I want to receive by email for my secret to my Apple ID issue because it is a gmail account. Please help me

    I forgot my secret question, answer and the second email but I have the password of my ID Apple and my phone number. I want to receive by email for my secret to my Apple ID issue because it is a gmail account. Please help me

    You have to ask Apple to reset your security questions. To do this, click here and choose a method; If this page does not list one for your country or if you are unable to call, complete and submit this form.


    (139026)

  • I forgot my security question answers and my email resue has a mistaket

    I forgot my security question answers and my email resue has a mistaket

    You have to ask Apple to reset your security questions. To do this, click here and choose a method; If this page does not list one for your country or if you are unable to call, complete and submit this form.

    (137726)

  • Emailing to my question mark and supervise the work on the first, then the small e accent when arrives to her frame them and the capital E with the accent comes for the question mark.

    get the e french instead of the question mark or frame them

    Emailing to my question mark and supervise the work on the first, then the small e accent when arrives to her frame them and the capital E with the accent comes for the question mark.  Can you tell me what is the cause and how to fix it.  Thank you.

    Hello

    I suggest you according to the question in this forum and check if that helps:

    http://windowslivehelp.com/forums.aspx?ProductID=15

    It will be useful.

  • I asked a question? and I'm not.

    I asked a question? and I'm not.

    Lucy

    You can click on your username in the upper right corner, and it will take you to your profile page where are all your questions (and everything else).

    http://answers.Microsoft.com/en-us/profile/02cee6c7-D2C2-4387-adf3-5c19df6c6905  It is also your profile page

  • I asked a question yesterday and cannot find it.please help

    I asked a question yesterday and can't find it.

    Hi Jennifer,.

    It's here: http://answers.microsoft.com/en-us/protect/forum/protect_other-protect_scanning/i-cant-download-anything/c4590e65-a61a-45e6-8f00-3d2f75d77d52.

    For the future, just click on the name at the top right of the screen to go to your profile and then page you click the Questions tab.  All the questions you ever wondered are there and you can then select the one you want and click on it to go.

    Best wishes!

    Kosh

  • I have a Leica LR but my creative cloud annual subscription has expired, my Lightroom my LR library for 2015 and beyond now has a question mark and I can't open pictures

    I have a subscription valid and active Leica camera.

    How can I get Adobe to recognize? My creative cloud has expired. I'm frozen out of my photo library

    Using the redemption code Leica I downloaded successfully updated day to day LR 6 but my LR library for 2015 and beyond now has a question mark, and I can't open the images.

    Any suggestions?

    Is this something that Adobe has to rectify?

    Thank you

    John

    The question mark has nothing to do with your subscription at the end. The question mark on your records indicates that Lightroom cannot find the photos, because they have been moved or renamed, or delete outside of Lightroom. The instructions to fix it are: Adobe Lightroom - find folders and files moved or missing

  • Question design and update

    Hello community,

    I have a following question design and update on vSphere 6 with MRS.


    In out of our subsidiaries, we have configured following installation:

    -VMware vSphere 5.5 environment with Site Recovery Manager that runs on 5.8 installed U3.
    -Two vCenter server running in a configuration in linked mode, so you only need access to a vCenter server to see both sides.

    No, we want to upgrade to vSphere 6 and here I have some question how says it in the best conditions.
    Wouldn't be a good thing or maybe it's mandatory to have a service of external platform controller installed in the vSphere environment and then start the upgrade to vSphere 6 each side has its 'own' PSC.

    Thanks for some tips and training on your side.

    Did you read the documentation regarding the upgrade to SRM 6 located here: Site Recovery Manager 6.0 Documentation Center

    Who will answer all you questions, including your subject to PSC. A short summary, you want a PSC for each site. The reason is that you want that each site to be completely independent of the other.

    If read you the docs and you still have questions, please post them.

  • First, I'm joining the forum with a question CS4 and CS5 Suite for Mac. Can someone tell me why it is NOT a place to submit a question as it is here?

    First, I'm joining the forum with a question CS4 and CS5 Suite for Mac. Can someone tell me why it is NOT a place to submit a question as it is here?

    Creative Suites Mac forum seems to be closed, so moved that Creative Suites Windows the Forum of Creative Suites "base".

    Then... Post your question and someone may be able to help... is your question about the installation of the old software on a new Mac?

    IF El Capitan Mac read below

    CS6 and previous programs have not been tested and will not be updated to run on Mac El Capitan

    -which means you are trying to use CS6 and earlier at YOUR risk of having problems

    -You can get CS6 and previous programs to install and run, or you can not (some do, some don't)

    -IF not, Details of the message from the error messages and a person may be able to help (just not Adobe)

    This information is a MUST to install old programs on Mac El Capitan

    -You can't get the same error message, but here are some links that CAN help with old programs

    -Java https://helpx.adobe.com/dreamweaver/kb/dreamweaver-java-se-6-runtime.html can help

    Install CS5 on Mac 10.11 https://forums.adobe.com/thread/2003455 can help (also for others than CS5)

    -also a TEMPORARY security change https://forums.adobe.com/thread/2039319

    -http://mac-how-to.wonderhowto.com/how-to/open-third-party-apps-from-unidentified-developer s-mac-os-x-0158095 /

    -the guardian https://support.apple.com/en-au/HT202491

  • What is the difference between PhoneGap and Cordova?

    Hello

    I wonder what is the difference between PhoneGap and Cordova?

    -brett

    There is a blog that addresses this issue: http://phonegap.com/2012/03/19/phonegap-cordova-and-what%E2%80%99s-in-a-name/

    But at the bottom: 'PhoneGap's distribution Apache Cordova. You can consider the engine that propels PhoneGap Cordova Apache, similar to how WebKit is the engine that propels Chrome or Safari. »

  • Chronology of novice question

    Friendly assistance requested please!

    Maybe there's another way to do it? After several hours of error and watch stuff on Lynda.com Im still stuck.

    I'm new to Actionscript and try to fall along using the Code Snippts so I'd appreciate any help. I could normally get this all work if I put everything in a timeline. However, I tried to clean my calendar and I noticed a lot of videos have been people have 4 or 5 layers on the main timeline and then add the rest. Any help would be greatly appreciated.

    My calendar has 4 layers in the following order:

    • Actions
    • Buttons
    • Main
    • BG

    Question 1:

    1. main (inter-generational: Movieclip) has incorporated a Tween who plays as soon as I test the movie. I can't stop this by adding a "stop();" on the first picture in the embedded timeline. Curiously, however, the film will continue to play if the "stop();" is placed as part of frist on the main timeline.  Why is this the case?

    Question 2 (and my main problem):

    2. I have 3 buttons (forward, backward and Stop) currently im using just forward until I make it work properly. I want the 'next' button to continue to act as the button image following throughout the film, but I also need the key to advance to the interpolation integrated within the Movieclip of the hand. How can I get the button "Next" to access the interpolation into the movieclip?

    Currently my next button has the following code:

    ________________________________________________________________

    Play_btn.addEventListener (MouseEvent.CLICK, fl_ClickToGoToNextFrame_11);

    function fl_ClickToGoToNextFrame_11(event:MouseEvent):void
    {
    nextFrame();
    }

    ________________________________________________________________

    So I thought that if I added another action on the layer in the second picture 'Hand' it advance to the embeded interpolation and read it.

    ______________________________________________________________________________

    Main.addEventListener (MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_5);

    function fl_ClickToGoToAndPlayFromFrame_5(event:MouseEvent):void
    {
    gotoAndPlay ("WesternWayOfWar");
    }

    ______________________________________________________________________________

    Thank you, David

    If you want to click the movieclip of the hand and have it play and that the code is located in the timeline that holds this movieclip, then you must use...

    Main.addEventListener (MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_5);

    function fl_ClickToGoToAndPlayFromFrame_5(event:MouseEvent):void
    {
    Main.gotoAndPlay ("WesternWayOfWar");
    }

    If you wanted the movieclip hand just play when you get to this image of the chronology of container, then you can simply use...

    Main.gotoAndPlay ("WesternWayOfWar");

  • How do I to the previous screen in android using phonegap and store data in ios

    Hello

    I use phone of gap technology, in android how previous screen.actually go, I used navigator.app.backHistory () orwindow.history.back () ' its fine for blackberry or ios .but does not not in android... Please suggest...

    Question 2) how to store data in ios?
    I used (window.localStorage, it works very well with android and blackberry not ios.why)
    Thank you

    Hello

    I think you'll have more chance of Phonegap Google Group for your Android questions as everyone is here to help specific BlackBerry.

    https://groups.Google.com/Forum/?fromgroups#! Forum/phonegap

  • PhoneGap and Bluetooth plugin

    Hello everyone!

    First of all, I ask that you forgive for my English...

    I try to use a plugin of cordova/phonegap for bluetooth connection. You can find it->here< -.

    When I use methods such as bluetoothSerial.connect (of course with my MAC address) or simply when I use examples with Arduino, nothing works.

    It's as if the plugin methods stop the progress of the code, but no error message appears in the console.

    I have install the plugin with

    cordova plugin add cordova-plugin-bluetooth-serial

    Maybe I forgot to do something, and so it does not work...

    Can someone help me with this plugin?

    Or someone who already use Bluetooth in a project phonegap/Cordoba?

    Thank you and sorry for my English.

    Well, it's part of the problem:

    
    

    You should only use the following version:

     
    

    In addition, the current version of the plugin in question is 0.4.5, not 1, so I review your plugin tag accordingly:

    
    

    In addition, the white list plugin has more recent versions as well, so you can update this tag:

    
    

    Finally, how do you test your app? You use "cordova run android" or you use the PhoneGap Desktop/Developer app?

    Note: You can embed the code by switching to the advanced and then view editor by clicking on the ">" button in the toolbar, and then selecting 'Syntactic' and selecting the language of your choice. It's a little buried, unfortunately.

Maybe you are looking for

  • New OS for old Tecra 8000

    Hi all I just purchased a Qosmio F10 and want to give my old Tecra 8000 (P2 300 Mhz, 8 GB, 192 MB of RAM) to a friend. This computer works fine on Windows 98 1st edition, and I again all the installation diskettes. I would like to reformat the drive

  • Unable to send/receive email from Apple Mail.

    My Comcast email no longer works in Apple Mail on my iMac. How can I change the e-mail settings for the type of IMAP instead of POP account? I have OS X El Capitan 10.11.3 on my iMac. Spoke to a Comcast technician this morning which says I should con

  • TTI QL355TP Install Instructions

    I do an installation instructions for QL355TP fast. This tutorial is attached to this message. I'm sorry, it's only in Spanish. ------------ He has created una pequeña Guía para instalar the QL355TP. Esta Guía esta adjunta an este message. Lo siento,

  • Windows Search can not find any file with 'two letters'-'two letters', followed by the numbers i.e. FS-XP1234

    It's a weird thing, these files are located on a network drive, but I also tested in a local folder with the same results. Examples of questions: Folder containing the following files FS - XP12345.pdf FS - XP54321.txt 124234Sample12.PDF If I where to

  • How to check if a file is already open

    My question is about subject local filesystem "file." I write a function that reads the contents of a text file. The function a "File" object is passed as an argument and then reads the contents before another logic.Before you can read a "File" objec