Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to post Json data on server in using ajax
    primarykey
    data
    text
    <p>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</p> <pre><code>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"} </code></pre> <p>Here is my Url</p> <pre><code>public static String fsReportUrl = "http://50.57.145.165:8180/FTPEReport/ftpereports/fsreport?fsReport="; </code></pre> <p>Now I need to Post this using query .Here is my fiddle. <a href="http://jsfiddle.net/ravi1989/NKBUF/2/" rel="nofollow">http://jsfiddle.net/ravi1989/NKBUF/2/</a></p> <pre><code>&lt;div data-role="page" id="Home" &gt; &lt;div data-role="content"&gt; &lt;label for="name" style="text-align:top;margin-left: 0px;" &gt;conductorName:&lt;/label&gt; &lt;input name="name" id="name" value="" type="text" class="Name_h" autocorrect="off"&gt; &lt;label for="deport" style="text-align:top;margin-left: 0px;" &gt;Deport:&lt;/label&gt; &lt;input name="deport" id="deport" value="" type="text" class="deport_h" autocorrect="off"&gt; &lt;label for="dateandTime" style="text-align:top;margin-left: 0px;" &gt;dateTime:&lt;/label&gt; &lt;input name="dateandTime" id="dateandTime" value="" type="date" class=""&gt; &lt;label for="origin" style="text-align:top;margin-left: 0px;" &gt;origin:&lt;/label&gt; &lt;input name="origin" id="origin" value="" type="text" class=""&gt; &lt;label for="dest" style="text-align:top;margin-left: 0px;" &gt;Destination:&lt;/label&gt; &lt;input name="dest" id="dest" value="" type="text" class=""&gt; &lt;label for="headcode" style="text-align:top;margin-left: 0px;" &gt;Headcode:&lt;/label&gt; &lt;input name="headcode" id="headcode" value="" type="text" class=""&gt; &lt;label for="devicepin" style="text-align:top;margin-left: 0px;" &gt;Devicepin:&lt;/label&gt; &lt;input name="devicepin" id="devicepin" value="" type="text" class=""&gt; &lt;div data-role="fieldcontain"&gt; &lt;fieldset data-role="controlgroup"&gt; &lt;input type="checkbox" name="checkbox-1" id="checkbox-1" class="custom" /&gt; &lt;label for="checkbox-1"&gt;customersInvited&lt;/label&gt; &lt;input type="checkbox" name="checkbox-2" id="checkbox-2" class="custom" /&gt; &lt;label for="checkbox-2"&gt;customersunInvited&lt;/label&gt; &lt;input type="checkbox" name="checkbox-3" id="checkbox-3" class="custom" /&gt; &lt;label for="checkbox-3"&gt;customerLeft&lt;/label&gt; &lt;input type="checkbox" name="checkbox-4" id="checkbox-4" class="custom" /&gt; &lt;label for="checkbox-4"&gt;noFirstClassImpact&lt;/label&gt; &lt;/fieldset&gt; &lt;/div&gt; &lt;a href="#" data-role="button" data-corners="false" id="callJsonFunfunction"&gt;Call webservice&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>I think using ajax we will do essily .?</p> <p>I am using like that in BB.</p> <pre><code>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; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload