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;
            }
        });
    });
6
  • Try renaming your submit method name to something else. I've had issues in the past using common names for the methods. Commented Aug 8, 2013 at 23:47
  • Default escape is true, you do not need to include that as a paramater.
    – Adrian Larson
    Commented Aug 9, 2013 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
    Commented Aug 9, 2013 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
    Commented Aug 9, 2013 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 Commented Aug 9, 2013 at 7:13

1 Answer 1

1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .