Page 1 of 1

How to use $.ajax instead of service?

Posted: Thu Jul 23, 2015 6:02 am
by Reynaldo Libutan

I want to use jquery $.ajax() because I am experiencing difficulties with POSTing complex object via JSON through your service wrapper.

I tried the usual $.ajax() but I am stopped by cross-domain violation. Is there something I need to do to be able to use $.ajax() using Appery proxy without using the service wrapper?


How to use $.ajax instead of service?

Posted: Thu Jul 23, 2015 1:37 pm
by Reynaldo Libutan

Any news on this?


How to use $.ajax instead of service?

Posted: Sat Jul 25, 2015 12:50 am
by Illya Stepanov

Hi -

Please take a look in our documentation how proxy URL should look like in the app: https://devcenter.appery.io/documenta...

Here is a sample code of a AJAX request from our Database:

pre
code
$.ajax({
type: "GET",
beforeSend: function(request) {
request.setRequestHeader("X-Appery-Database-Id", "5166b6a8e4b055aafd1f2167");
},
url: "https://api.appery.io/rest/1/db/collections/todo",
data: {
where: JSON.stringify({Name:"name2"})
},
dataType: "json",
success: function(response) {
console.log("Successfully loaded");
},
error: function(xhr, ajaxOptions, thrownError) {
console.log("Load error: " + xhr.status + " " + xhr.responseText);
}
});

/code
/pre