+ Start a Discussion

Best practice Javascript apex/Visualforce

I have a usecase which can be either achieved by

1)create a custom button

2)add javascript

3)call apex global webservice class [all apex function to be called from JS should be global webservice]which has the logic of updating database


1)create a custombutton

2)add javascript

3)redirect to a VF page

4)VF extension controller handles logic

Which is a best way to do this?I went for second thinking,more webservices might not be a good thing.But does anyone know what should be the approach to be taken in such cases

Best Answer chosen by Admin (Salesforce Developers) 
Webservices uses API calls, but Visualforce doesn't. It would therefore be advisable to use the VF page over a webservice call.