<!DOCTYPE html>
    <html lang="en">
        <head>
            <meta charset="utf-8">
                <title>Jaggery - Delicious Javascript</title>
                <meta name="description" content="">
                    <meta name="author" content="">

                        <!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
                        <!--[if lt IE 9]>
                        <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
                        <![endif]-->

                        <!-- Le styles -->
                        <link href="../css/bootstrap.css" rel="stylesheet">
                            <style type="text/css">
                            body {
                                padding-top: 60px;
                                }
                            </style>
                            <link href="../css/prettify.css" rel="stylesheet">
                                <!-- Le fav and touch icons -->
                                <link rel="shortcut icon" href="../images/favicon.ico">
                                    <link rel="apple-touch-icon" href="../images/apple-touch-icon.png">
                                        <link rel="apple-touch-icon" sizes="72x72"
                                        href="../images/apple-touch-icon-72x72.png">
                                            <link rel="apple-touch-icon" sizes="114x114"
                                            href="../images/apple-touch-icon-114x114.png">
                                            </head>

                                            <body>

                                                <%
                                                include('/includes/topnavi.jag');
%>

<div class="container-fluid" style="width: 960px; margin: auto;">
<div class="row">
    <div class="span16">
        <div class="page-header">
            <h1  id="top">
                Documentation
                <small>API documentation for Jaggery.js</small>
            </h1>
        </div>
    </div>
</div>

<div class="row">
<div class="span4">
    <div class="well">
        <%
        include('/includes/navi.jag');
        %>

    </div>

</div>
<div class="span12">
<div class="content" id="post" name="post">
<h3>post()</h3>

<pre class="prettyprint linenums">
&lt%
var url = 'http://jaggeryjs.org/apidocs/resources/data.jag';
var result = post(url, 'Jaggery HTTP POST', {
    "User-Agent" : "Jaggery-XHR",
    "Country" : "LK"
}, 'json');
print(result.data);
%&gt
</pre>
<%
var emailCode = '&lt%'
+ "\n var url = 'http://jaggeryjs.org/apidocs/resources/data.jag';"
+ "\n var result = post(url, 'Jaggery HTTP POST', {"
+ '\n   "User-Agent" : "Jaggery-XHR",'
+ '\n   "Country" : "LK"'
+ "\n }, 'json');"
+ "\n print(result.data);"
+ "\n %&gt";

var codeSnip = encodeURIComponent(emailCode);
var urlString = '../tryitframe.jag?code='+codeSnip;

include('/includes/tryit_but.jag');
%>

    <div id="pageLinks">
        <a class="navilink" href="#overview">Overview</a>
        <%if(hasParams) {%>
        <a class="navilink" href="#parameters">Parameters</a>
        <%}%>
        <%if(hasRets) {%>
        <a class="navilink" href="#returnVals">Return values</a>
        <%}%>
    </div>

<section id="overview">

<h4>Overview</h4>
<p class="description"><code>post()</code> is a wrapper for XMLHTTPRequest's POST method. Using
<code>post()</code> you can avoid the use of XHR and shorten the serverside POST requests. If the
<code>Content-Type</code> header is not specified, <code>application/x-www-form-urlencoded; charset=UTF-8</code>
will be set automatically.</p>
    <p><strong>Asynchronous Invocation</strong></p>
    <pre class="prettyprint">post(url[, data][, headers][, type][, success(data, xhr)])</pre>
    <p><strong>Synchronous Invocation</strong></p>
    <pre class="prettyprint">var res = post(url[, data][, headers][, type])</pre>
    <p class="description">Returned result contains the data and the XMLHttpRequest instance.
    <code>{ data: {}, xhr: {} }</code></p>
</section>

    <section id="parameters">
        <h4>Parameters</h4>
        <table class="clsStd operations-table">

            <tbody>

            <tr>
                <th>Parameter</th>
                <th>Type</th>
                <th>Description</th>
            </tr>

            <tr>
                <td><code>url</code></td>
                <td>String</td>
                <td>The URL which HTTP POST is performed </td>
            </tr>
            <tr>
                <td><code>data</code></td>
                <td>Object|String</td>
                <td>Request parameters</td>
            </tr>
            <tr>
                <td><code>headers</code></td>
                <td>Object</td>
                <td>Optional HTTP headers.
<pre class="prettyprint">{
    "Content-Type": "application/json",
    "User-Agent": "Mozilla/5.0",
    "Cookie": "JSESSIONID=4DA02FE19BA086964227"
}</pre>
                </td>
            </tr>
            <tr>
                <td><code>type</code></td>
                <td>String</td>
                <td>The type, which the response is expected. Allowed types are <code>json, xml</code> or <code>text</code>.
                Returned response will be serialized either to an object, E4X XML or string depending on the value passed.
                <code>text</code> is the default value.</td>
            </tr>
            <tr>
                <td><code>success(data:Object,<br/> xhr:Object)</code></td>
                <td>function</td>
                <td>On success callback. <code>data</code> will be passed according to the above mentioned
                <code>type</code> parameter passed during the invocation.</td>
            </tr>
            </tbody>
        </table>
    </section>


    <section id="returnVals">
        <h4>Return values</h4>
        <table class="clsStd operations-table">
            <tbody>
            <tr>
                <th>Value</th>
                <th>Type</th>
                <th>Description</th>
            </tr>
            <tr>
                <td><code>data</code></td><td>Object</td><td>Contains the return data of the HTTP POST request</td>
            </tr><tr>
                <td><code>xhr</code></td><td>Object</td><td>Contains an instance of XMLHTTPRequest</td>
            </tr>
            </tbody>
        </table>
    </section>
</div>
<!-- /post div -->
<br>
<br>
</div>

</div>
<%
include('/includes/footerfunc.jag');
%>


</div>
<!-- /container -->
<%
include('/includes/scripts.jag')
%>

	<script>

		$(document).ready(function(){
        $('#post').toggleClass('active')
		$('#docs').addClass('active')
        });




	</script>
</body>
</html>