0

When i run below code on button click event, it is not working.

<apex:page >
   <apex:form >
      <apex:includeScript value="{!$Resource.jqueryAvaWidget}"/>
      <div id="avalaraDiv" style="height:500px;width:1000px;">Div</div>
      <script>
         function test() {
         alert('in test function');
          $("#avalaraDiv").AvaWidget({
           InheritCss:true,
           AvalaraOnboardingObject: new AvalaraOnboarding("Test Connector","company_name","000000000", "address_line_1", "address_line_2", "address_line_3", "address_city", "", "state", "zipCode", "email", "firstname", "lastname", "phone"),                                                                                              
           onAvaTaxCompanyCreated: function (onboardingData) { alert(JSON.stringify(onboardingData)); }
            });
         }
      </script>
      <!-- Begin Default Content REMOVE THIS -->
      <apex:commandButton value="Test" onclick="test()" />
   </apex:form>
</apex:page>

Can anyone help me to sort out please.

closed as off-topic by Adrian Larson, Sebastian Kessel, Ratan Paul, Tushar Sharma, crmprogdev Jun 13 '16 at 19:22

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Programming questions not specific to Salesforce are off-topic here, but can be asked on Stack Overflow." – Adrian Larson, Sebastian Kessel, Ratan Paul, Tushar Sharma, crmprogdev
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    Try using an HTML button instead of an <apex:commandButton>. This may be a case of unexpected behavior of the VF component. – ca_peterson Jan 16 '16 at 7:49
  • 2
    - Bhavesh, which jquery plugin you are using? – Ratan Paul Jan 16 '16 at 14:56
1
Hi Bhavesh,

In order to use jQuery in your visualforce, either you have to load the jQuery js file as a Static Resource in salesforce or you can use the CDN's.
I think you are not able to use jQuery js file as a Static Resource in salesforce.
So, I suggest you to use CDN's Method.

you have to replace this code
 <apex:includeScript value="{!$Resource.jqueryAvaWidget}"/>
 by
 <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" />


 For more details you can also visit following link
 https://developer.salesforce.com/page/Developing_Apps_with_jQuery

 Regards,
 Ajay
  • 1
    This answer is incorrect. It s 100% possible to use a Static Resource to load jQuery. – Adrian Larson Jun 13 '16 at 14:22
  • Thanks Adrian. I agree and know that we can use Static Resource to load jQuery. I was suggesting an alternate method of using CDN. – Ajay Dubedi Jun 14 '16 at 7:46

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