• Anand Sengunthar
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
Hi All,
 I am trying to call apex from javascript.  Wrote the below script

<script src="/soap/ajax/15.0/connection.js" type="text/javascript">
</script> <script src="/soap/ajax/15.0/apex.js" type="text/javascript"></script>
var r= confirm ("Are you sure you want to fetch?");
if(r== true)
{
   var a = sforce.apex.execute("web","fetch",{ID: "{!Account.Id}"});
   alert(a);
}
else
{
   alert("Operation aborted");
}

I have already the class named 'web' with method 'fetch'.  I wrote the above script on a button.  When I click on that button,  I get an error 'Unexpected token < '
On debugging , i found issue with the two lines defining the ajax connection and apex.js.  can anyone help what is wrong with the code.