I am using wrapper class to fetch the consumer object values and passed into Data table,

In that I am using consumer code and consumer name are the two text boxes.

Once I am enter the Consumer code, I need to make a Webservice call via javascript(not in apex code) and fetch the customer name from external webservice.

How to do that?

Plese share the sample code also if possible.

  • Any reason why you dont want to make a call through apex class? – Mohith Shrivastava Dec 24 '12 at 12:27
  • 2
    If you're not using Apex, just do it the same way you would make any other webservice or ajax call from javascript -- it doesn't really matter that you're using Salesforce at that point. – Benj Dec 24 '12 at 14:01
  • 3
    Also, please include the relevant lines of your Visualforce page and/or html to help us understand your need and how we could help answer your question. – Benj Dec 24 '12 at 14:02

Sounds like you want to utilize the AJAX toolkit:


| improve this answer | |

It could look like this, if your webservice method return a string:

<apex:includeScript value="/soap/ajax/20.0/connection.js" />
<apex:includeScript value="/soap/ajax/10.0/apex.js" />

var custName = "" + sforce.apex.execute("WebServiceClass","yourMethod", 
| improve this answer | |

Hey You can use Javascript remoting to call a method in the controller, from the controller method call your webservice and return the desired value.

For more details on apex remoting please go through the following link http://www.salesforce.com/us/developer/docs/pages/Content/pages_js_remoting.htm

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.