In this blog we will learn how to send post request through AJAX in Visualforce page using jquery. Let’s get started.

POST Request through AJAX in Visualforce

The code is mentioned below:

<apex:page >
         * Webkul Software.
         * @category  Webkul
         * @author    Webkul
         * @copyright Copyright (c) 2010-2016 Webkul Software Private Limited (
         * @license
  <apex:includeScript value=""/>
    jQuery(document).ready(function($) {
      // Get Accounts via the REST API
          data:'{"Name":"Test Company"}',
          dataType: 'json',
          beforeSend: function(xhr) {
            // Set the OAuth header from the session ID
            xhr.setRequestHeader('Authorization', 'Bearer {!$Api.Session_ID}');            
            xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
          success: function(response) {
            // Sit the result to HTML div          
          error: function(jqXHR, textStatus, errorThrown) {
            // Error
            alert(jqXHR.status + ': ' + errorThrown);
  <h1>REST API (POST method)</h1>
  <div>Account Info:</div>
  <div id="accountId">


post request through ajax


That’s all for how to send Post Request through AJAX in Visualforce page using jquery, still have any issue feel free to add a ticket and let us know your views to make the code better


Leave A Reply

Please verify that you are not a robot.

Tell us about Your Company

How can we help you with your business?

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home