Ajax post data in android java -
i new t ajax, quite familiar android. converting ajax program android app. part of it, need post data server. below given post command in ajax.
var postto = 'xyz.php'; $.post(postto,{employee_name: $('[name=employee_name]').val() , phone: $('[name=phone]').val(), employee_type: 'guest' } , function(data) { if(data.success){ window.localstorage["sa_id"] = data.mid; window.location="getempdb.html"; } if(data.message) { $('#output').html(data.message); } else { $('#output').html('could not connect'); } },'json');
i want implement in android under little above statements. @ ajax me out thing. of now, user name , telephone number edit text input. need send php using http client. know how send data using php, not know format send , whether string send or json object send. please in interpreting above code , oblige.
apparently, uses urlencodedformentity
if using httpclient
in android.
this created using list of namevaluepair
.
from parameters $.post:
{employee_name: $('[name=employee_name]').val() , phone: $('[name=phone]').val(), employee_type: 'guest' }
you have create namevaluepair employee_name
, 1 phone
... each of fetched html element name employee_name
, phone
... put values edittexts.
it returns json formatted string, have parse (typically using jsonobject obj = new jsonobject(result);
once have fetched result server)
in json object, have key named success
, format not specified, except can assume things went if present ; key mid
, , key message
.