Javascript 如何将数据发送到网页html
我有一个应用程序。当点击提交==>我的网页将显示结果。但我不知道如何使用javascript json。有人帮我吗?非常感谢 对不起,我没有什么英语,所以 ==>它是我的android应用程序 ==>这是我的网页(图片和代码)Javascript 如何将数据发送到网页html,javascript,android,html,json,Javascript,Android,Html,Json,我有一个应用程序。当点击提交==>我的网页将显示结果。但我不知道如何使用javascript json。有人帮我吗?非常感谢 对不起,我没有什么英语,所以 ==>它是我的android应用程序 ==>这是我的网页(图片和代码) 函数myFunction(){ document.getElementById(“myid”).value=$ab; } 要显示的文本在页面中的何处?添加一个id为的div,然后更新它…页面中要显示的文本在哪里?添加一个id为的div,然后更新它。。。 <h
函数myFunction(){
document.getElementById(“myid”).value=$ab;
}
要显示的文本在页面中的何处?添加一个id为的div,然后更新它…页面中要显示的文本在哪里?添加一个id为的div,然后更新它。。。
<html>
<head>
<script>
function myFunction() {
document.getElementById("myid").value=$ab;
}
</script
</head>
<body onload="myFunction()">
<input id="myid" type="text" />
</body>
</html>
public class ChennaiIntent extends Activity implements OnClickListener{
private EditText value;
private Button btn;
private ProgressBar pb;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
value=(EditText)findViewById(R.id.editText1);
btn=(Button)findViewById(R.id.button1);
pb=(ProgressBar)findViewById(R.id.progressBar1);
pb.setVisibility(View.GONE);
btn.setOnClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
public void onClick(View v) {
// TODO Auto-generated method stub
if(value.getText().toString().length()<1){
// out of range
Toast.makeText(this, "please enter something", Toast.LENGTH_LONG).show();
}else{
pb.setVisibility(View.VISIBLE);
new MyAsyncTask().execute(value.getText().toString());
}
}
private class MyAsyncTask extends AsyncTask<String, Integer, Double>{
@Override
protected Double doInBackground(String... params) {
// TODO Auto-generated method stub
postData(params[0]);
return null;
}
protected void onPostExecute(Double result){
pb.setVisibility(View.GONE);
Toast.makeText(getApplicationContext(), "command sent", Toast.LENGTH_LONG).show();
}
protected void onProgressUpdate(Integer... progress){
pb.setProgress(progress[0]);
}
public void postData(String valueIWantToSend) {
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://11.10.88.2/tuan/example.html");
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("myHttpData", valueIWantToSend));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
}
}
}