4

I have a VF page with very few input HTML tags and I want to pass these values to the controller via javascript remoting on a click of Submit. I see that my submit function is being called but for some reason the method on the controller is not called. I went over and over but the code seems to be fine. This is what I wrote, do you see any issue?

My Controller method:

global with sharing class ReservationController {    
  @RemoteAction
  global static boolean Submit(string FName, string LName, string Email, string Phone,                   
                               string Company, string Website){
       system.debug('in submit');
  }
}

My javascript:

<script type="text/javascript">

    $(document).ready(function(){

        $('#form1').submit(function(){
            var ok = true;

           ...some code...

            if(ok){
                //submit
                console.log("form ok");                 

                Visualforce.remoting.Manager.invokeAction(
                    '{!$RemoteAction.ReservationController.Submit}',
                     $('#firstName').val(), $('#lastName').val(), $('#theEmail').val(),  
                     $('#thePhone').val(), $('#theCompany').val(), $('#theWebsite').val(),
                     function handleResult(result, event) { alert(result); },
                     {escape: true}
                );                  
            }
            else{
                console.log("form not ok");
                return false;
            }
        });
    });
  • Try renaming your submit method name to something else. I've had issues in the past using common names for the methods. – Boris Bachovski Aug 8 '13 at 23:47
  • Default escape is true, you do not need to include that as a paramater. – Adrian Larson Aug 9 '13 at 0:15
  • Everything looks perfect, instead of passing parameters directly, try to assign to variables and use them in call like var fname = $('#firstName').val(); – Venkatesh Aug 9 '13 at 4:46
  • I've followed all of your suggestions but still the controller method is not being invoked. Any advice how to debug this? – Dedo Aug 9 '13 at 6:53
  • one way is use alerts at all single lines and see till where your execution stops .Also try to see if there are no plugin dependency issues thats occuring.Hope this helps – Mohith Shrivastava Aug 9 '13 at 7:13
1

Make sure the apex page has your controller set as the page controller?

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.