Skip to content
This repository was archived by the owner on Jan 10, 2024. It is now read-only.
This repository was archived by the owner on Jan 10, 2024. It is now read-only.

forcetk.Client.prototype.ajax not working . #62

@ramsabarish

Description

@ramsabarish

I have created a hybrid salesforce app through forceios and I'm able to show all contacts.

But now I want show the Reports so I used REST API, but the method

forcetk.Client.prototype.ajax

is not getting called and there was no error shown in xcode or browser.

I have shared the code with you, Kindly help me out...

function callback(result){

alert("results");

}

function getReports(){

var path = '/v29.0/analytics/reports/00OD0000001ZbP7MAK/instances';

var method = 'POST';

var error = null;

var payload = null;

var retry = null;


alert("1");

forcetk.Client.prototype.ajax = function(path, callback, error, method, payload, retry) {

    alert("2");

    var that = this;

    var url = this.instanceUrl + '/services/data/v29.0/analytics/reports/00OD0000001ZbP7MAK/instances';

    alert(url);

    return $j.ajax({
                   type: method || "GET",
                   async: this.asyncAjax,
                   url: (this.proxyUrl !== null) ? this.proxyUrl: url,
                   contentType: method == "DELETE"  ? null : 'application/json',
                   cache: false,
                   processData: false,
                   data: payload,
                   success: callback,
                   error: (!this.refreshToken || retry ) ? error : function(jqXHR, textStatus, errorThrown) {

                   alert("error");

                   if (jqXHR.status === 401) {


                   that.refreshAccessToken(function(oauthResponse) {
                                           that.setSessionToken(oauthResponse.access_token, null,
                                                                oauthResponse.instance_url);
                                           that.ajax(path, callback, error, method, payload, true);
                                           },
                                           error);
                   } else {
                   error(jqXHR, textStatus, errorThrown);
                   }
                   },
                   dataType: "json",
                   beforeSend: function(xhr) {
                   if (that.proxyUrl !== null) {
                   xhr.setRequestHeader('SalesforceProxy-Endpoint', url);
                   }
                   xhr.setRequestHeader(that.authzHeader, "OAuth " + that.sessionId);
                   xhr.setRequestHeader('X-User-Agent', 'salesforce-toolkit-rest-javascript/' + that.apiVersion);
                   }
                   });
}

} //End of getReports

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions