Base solution for your next web application
Open Closed

abp.ajax vs abp.services - some questions #7158


User avatar
0
dexmox created

Could someone please tell me what the benefits and differences are and which is better to use for doing ajax table updates and why ?

_personService.createPerson(person).done(function () {
                _modalManager.close();
                 // some ajax table updates and stuff here
            }).always(function () {
                _modalManager.setBusy(false);
            });

https://docs.aspnetzero.com/documents/aspnet-core-mvc/latest/Developing-Step-By-Step-Core-Saving-Person

VS

abp.ajax({
    url: '/People/SavePerson',
    data: JSON.stringify(newPerson)
}).done(function(data) {
    abp.notify.success('Created new person with id = ' + data.personId);
    // some ajax table updates and stuff here
});

https://aspnetboilerplate.com/Pages/Documents/Javascript-API/AJAX

Thanks in advance.


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @dexmox

    We suggest to use abp.services when possible since it handles urls, method types and formatting data objects to json string for you. It also provides more readable code to developers.

    If you are using Angular version, it is also type-safe.