1

I'm having an issue with javascript remoting that works in Chrome but fails in IE and Firefox on multiple machines. This used to work however. Below is the simplified code and I can confirm in debug logs that the locationLookup function is getting called and returning a string value but I don't even see the done popup. I've tried console logging out event and result and event.status but the page just reloads. It is being fired off of a form submit but the earlier logic is working fine. Thanks in advance.

`

<script type="text/javascript">
    var $j = jQuery.noConflict();
$j(function() {

    alert('searching1');
    Visualforce.remoting.Manager.invokeAction(
            '{!$RemoteAction.DD_Reg_0_Create_Controller.locationLookup}',
            '724 Massachusetts', 'Lawrence', 'KS', '66044', 'kevin.regtest8@driverdo.com', 
            function(result, event){
                alert('result1:' + result);
            },
            {escape: true}
        );

});


function submitForm() {

    alert('submitting');
    Visualforce.remoting.Manager.invokeAction(
        '{!$RemoteAction.DD_Reg_0_Create_Controller.locationLookup}',
        '724 Massachusetts', 'Lawrence', 'KS', '66044', 'kevin.regtest8@driverdo.com', 
        function(result, event){
            alert('result:' + result);
        },
        {escape: true}
    );

}

<apex:form id="theForm" html-name="theForm" forceSSL="true">
<apex:actionFunction action="{!saveLead}" name="saveLeadJS"/>
<apex:actionFunction action="{!saveOutOfMarket}" name="saveOutOfMarketJS" oncomplete="saveLeadJS();"/>
<apex:actionFunction action="{!duplicateusers}" name="duplicateUsersJS" />

<div class="solo centered">
    <div class="panel panel-primary" id="panel1">
        <div class="panel-header">
            <h4>
                Create a new account
            </h4>
        </div>

        <div class="panel-body">

            <apex:messages id="error" styleClass="alert danger"/>

            <div class="input-row">

                <div class="form-group duet">
                    <apex:outputlabel value="First Name" for="firstname"/>
                    <apex:inputfield id="firstName" styleClass="form-control" value="{!Contact.firstName}" />
                </div>

                <div class="form-group duet">
                    <apex:outputlabel value="Last Name" for="lastname"/>
                    <apex:inputfield id="lastName" styleClass="form-control" value="{!Contact.LastName}"/>
                </div>
            </div>

            <div class="input-row clearfix">
                <div class="form-group duet">
                    <apex:outputLabel value="Email" for="Email"/>
                    <apex:inputText id="email" styleClass="form-control" value="{!Contact.email}"/>
                </div>
                <div class="form-group duet">
                    <apex:outputLabel value="Phone" for="Phone"/>
                    <apex:inputText id="phone" styleClass="form-control" value="{!Contact.Phone}"/>
                </div>
            </div>

            <div class="input-row clearfix passwordRow">
                <div class="form-group duet">
                    <apex:outputLabel value="{!$Label.site.password}" for="Password"/>
                    <apex:inputSecret id="password" styleClass="form-control password" value="{!password}"/>
                </div>

                <div class="form-group duet">
                    <apex:outputLabel value="{!$Label.site.confirm_password}" for="confirmPassword"/>
                    <apex:inputSecret id="confirmPassword" styleClass="form-control passwordConfirm" value="{!confirmPassword}"/>
                    <apex:outputText value=""/>
                </div>
            </div>

            <div class='spacer>'></div>

            <div class="input-row clearfix">
                <div class="form-group solo">
                    <apex:outputlabel value="Street Address 1" for="street"/>
                    <apex:inputfield value="{!Contact.MailingStreet}" id="MailingStreet" styleClass="form-control" />  
                </div>
            </div>

            <div class="input-row clearfix">
                <div class="form-group solo">
                    <apex:outputlabel value="Street Address 2" for="street2"/>
                    <apex:inputfield value="{!Contact.Mailing_Street_2__c}" styleClass="form-control" id="MailingStreet2" />  
                </div>
            </div>


            <div class="input-row clearfix">
                <div class="form-group trio">
                    <apex:outputlabel value="City" for="city"/>
                    <apex:inputField value="{!Contact.MailingCity}" id="MailingCity" styleClass="form-control" /> 
                </div>
                <div class="form-group trio">
                    <apex:outputlabel value="State" for="state"/>
                    <apex:inputfield value="{!Contact.Resident_State__c}" id="MailingState" styleClass="form-control"/>
                </div>
                <div class="form-group trio">
                    <apex:outputlabel value="ZIP Code" for="zip"/>
                    <apex:inputfield id="zip" value="{!Contact.MailingPostalCode}" label="Zip" styleClass="form-control"/>
                </div>
            </div>
        </div>

        <div class="panel-footer text-right">
            <button onclick="submitForm();" id='submitBtn' class='btn green large'>Create Account</button>


        </div>
    </div>
</div>

</apex:form>    

`

controller code:

@RemoteAction global static String locationLookup(string street, string city, string state, string postalCode, string userEmail){ return 'true'; }

  • Can you post the vf code which is invoking this remoting method? – Salesforcesmarty Feb 1 '16 at 22:37
  • Browsers can exhibit different behavior with <input elements and <button elements and whether or not they cause their parent form to be submitted when they're clicked. Do you get the expected behavior if you change your onclick event to return false after calling your remoting function? <button onclick="submitForm(); return false;" – Mark Pond Feb 1 '16 at 23:54
  • The return false did it, must of been submitting the form before the response from the call. Thanks Mark! – Kevin Feb 2 '16 at 1:10

Your Answer

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

Browse other questions tagged or ask your own question.