I made one application on Blackberry development I post some data on server .I am able to do that .But Now I am learning jquery and jquery mobile .Now I need to post the data on server using query.I made my Ui in jquery Mobile .I need some help in posting the data on server . I did like in that Blackberry
Name gg
Depot Barrow
Turn No 1
Date/Time:28:07:2013 02:22
origin Ardwick
Dest barrow
Headcode: hnh
Status :No 1st class Impact
{"headcode":"hnh","destination":"Barrow","origin":"Ardwick","time":"28:07:2013 02:22","turnNumber":"1","depot":"Barrow","conductorName":"gg","devicePin":"123456.78.364813.8","noFirstClassImpact":"true","customersInvited":"false","customersUninvited":"false","customersLeft":"false"}
Here is my Url
public static String fsReportUrl = "http://50.57.145.165:8180/FTPEReport/ftpereports/fsreport?fsReport=";
Now I need to Post this using query .Here is my fiddle. http://jsfiddle.net/ravi1989/NKBUF/2/
<div data-role="page" id="Home" >
<div data-role="content">
<label for="name" style="text-align:top;margin-left: 0px;" >conductorName:</label>
<input name="name" id="name" value="" type="text" class="Name_h" autocorrect="off">
<label for="deport" style="text-align:top;margin-left: 0px;" >Deport:</label>
<input name="deport" id="deport" value="" type="text" class="deport_h" autocorrect="off">
<label for="dateandTime" style="text-align:top;margin-left: 0px;" >dateTime:</label>
<input name="dateandTime" id="dateandTime" value="" type="date" class="">
<label for="origin" style="text-align:top;margin-left: 0px;" >origin:</label>
<input name="origin" id="origin" value="" type="text" class="">
<label for="dest" style="text-align:top;margin-left: 0px;" >Destination:</label>
<input name="dest" id="dest" value="" type="text" class="">
<label for="headcode" style="text-align:top;margin-left: 0px;" >Headcode:</label>
<input name="headcode" id="headcode" value="" type="text" class="">
<label for="devicepin" style="text-align:top;margin-left: 0px;" >Devicepin:</label>
<input name="devicepin" id="devicepin" value="" type="text" class="">
<div data-role="fieldcontain">
<fieldset data-role="controlgroup">
<input type="checkbox" name="checkbox-1" id="checkbox-1" class="custom" />
<label for="checkbox-1">customersInvited</label>
<input type="checkbox" name="checkbox-2" id="checkbox-2" class="custom" />
<label for="checkbox-2">customersunInvited</label>
<input type="checkbox" name="checkbox-3" id="checkbox-3" class="custom" />
<label for="checkbox-3">customerLeft</label>
<input type="checkbox" name="checkbox-4" id="checkbox-4" class="custom" />
<label for="checkbox-4">noFirstClassImpact</label>
</fieldset>
</div>
<a href="#" data-role="button" data-corners="false" id="callJsonFunfunction">Call webservice</a>
</div>
</div>
I think using ajax we will do essily .?
I am using like that in BB.
public static String postJson(JSONObject jsonObj, String url) {
String response = ""; // this variable used for the server response
JSONObject postData = jsonObj;
String valueObj = "";
try {
UrlImpl fullUrl = new UrlImpl();
fullUrl.setBaseUrl(url);
valueObj = fullUrl.getFullUrl();
HttpConnection connection = (HttpConnection) Connector
.open(valueObj);
// set the header property
connection.setRequestMethod(HttpConnection.POST);
connection.setRequestProperty("Content-Length",
Integer.toString(postData.length()));
connection.setRequestProperty("Content-Type",
"application/json;charset=UTF-8");
byte[] postDataByte = postData.toString().getBytes("UTF-8");
OutputStream out = connection.openOutputStream();
out.write(postDataByte);
out.flush();
out.close();
int responseCode = connection.getResponseCode();
if (responseCode == HttpConnection.HTTP_OK) {
InputStream in = connection.openInputStream();
StringBuffer buf = new StringBuffer();
int read = -1;
while ((read = in.read()) != -1)
buf.append((char) read);
response = buf.toString();
}
connection.close();
} catch (Exception e) {
XLogger.error(DataAccess.class, " Error in post reports -- " + e);
}
return response;
}