Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8285219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:24:48+00:00 2026-06-08T11:24:48+00:00

I am trying the PhoneGap Plugin for Android app in my code.My HTML Strict

  • 0

I am trying the PhoneGap Plugin for Android app in my code.My HTML Strict 4 Code is as follows

CODE:

<!DOCTYPE html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<script type="text/javascript" charset="utf-8" src="phonegap-1.0.0.js"></script>
<script type="text/javascript" charset="utf-8" src="system.js"></script>
<script type="text/javascript">

var uname;

function validate(){    

    //uname = document.forms[0].elements[0].value;
    //var pass = document.forms[0].elements[1].value;

    uname=document.getElementById("i1").value;
    var pass=document.getElementById("i2").value;

    alert("Uname: "+uname+"\r\nPass: "+pass);

    if(!uname || uname === "" || !pass || pass === ""){

        alert("User Credentials are incorrect");

    }
    else{           

        //Make a webservice call
          post_data(uname,pass,postDataCB);     


    }

}

function postDataCB(retval){

    alert("In postDataCB()\r\nuname: "+uname);

}



</script>
</head>
<body>
   <form>
      User name: <input type="text" id="i1" name="username" value="GEO02-OTPUAT" /><br />
      Password:&nbsp;&nbsp;<input type="password" id="i2" name="pwd" value="aaa111" /><br />
      <button onclick="javascript:validate()">Submit</button><br />
  </form>

In My HTML, I have a Global Variable called uname. This variable is used in the callback function postDataCB(), But it comes as undefined. (I did alert and saw)
What I observed was when i remove the <form /> element from HTML Code, it seems to work.

So can any one plz tell me why it is happening and how to solve this issue.

CODE of post_data:

public PluginResult post_data(JSONArray funcargs, String jscallbackid){

    SuccessCallBack=funcargs.getString(0);
    FailureCallBack=funcargs.getString(1);
        uname= funcargs.getString(2);
    passw = funcargs.getString(3);      


    conn = new URL("http://www.subratlogin.com/login").openConnection();
    conn.setDoOutput(true);


    data += URLEncoder.encode(uname, "UTF-8") + "=" + URLEncoder.encode(passw, "UTF-8") + "&";

    //remove the unwanted & at the end of the string
    data = data.substring(0,data.length()-1);  

    ro = new OutputStreamWriter(conn.getOutputStream());
    ro.write(data);

    //Close the connection
    ro.close(); 

    try{

        rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));

        while ((line = rd.readLine()) != null)
        {
           sb.append(line);
        }

    //Close the connection
       rd.close();

    } catch (IOException e) {
        SendJS = "javascript:" + FailureCallBack + "('" + e.getMessage() + "')"; 
        sendJavascript(SendJS);
        return null;
    }

    SendJS = "javascript:" + SuccessCallBack + "('" + JSONObject.quote(sb.toString()); 

    if(jObj != null)
        SendJS += "','" +  jObj + "')";
    else if(StringParam != null)
        SendJS += "','" + StringParam + "')";
    else
        SendJS += "')";

    sendJavascript(SendJS);
    return null;    
 }

sry fr asking this type of question.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T11:24:49+00:00Added an answer on June 8, 2026 at 11:24 am

    You are not following the plugin spec at all and I don’t see any place where you setup a listener for deviceready.

    http://wiki.phonegap.com/w/page/36753494/How%20to%20Create%20a%20PhoneGap%20Plugin%20for%20Android

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to develop an android app with phonegap and LocalNotification plugin. I want
I am trying to develop a Phonegap (1.3) app on Android (2.1) with jQuery
Trying to make an app using phonegap 1.4.1 + phonegap's childbrowser plugin. I've been
In my phonegap iPhone app, while i am trying to load a html with
I have Phonegap's Facebook plugin working perfectly within my Android app. This plugin uses
I'm trying to a run PhoneGap 1.0.0 app on the Android 1.6 emulator. I
I was trying to invoke a webservice from phonegap android app using jQuery .ajax
I'm trying to create an Android (2.2) app using Phonegap (version 1.9.0) and jQuery
I'm trying to upgrade a phonegap-1.4.1 project that uses the LocalNotification plugin for Android
I'm trying to use PhoneGap DatePicker plugin (PhoneGap 1.5 (Cordova) in Xcode 4.2) for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.