3

I created a VF page published on Site (http://trapptosemplify-developer-edition.eu2.force.com/TR/Login)

On the page there is a button "Accedi" which trigger a script using RemoteAction for the LOGIN (Code on bottom).

The same code inside SFDC work correctly, but the on site doesn't work. I does not understand why this happen. I published all pages on Site and setted the visibility for all profiles, the same for the controller...

anyone can help me? THNK K.

JSCRIPT:

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

 function loginUser() {
    var name = j$('#name').val();
    var password =j$('#password').val();        
    var namespace = 'TRRemoteActions.loginAccount';
    alert("ok");
    Visualforce.remoting.Manager.invokeAction(namespace, name, password, function(result, event){
                if (event.status) {
                    window.location = result; 
                } else {
                    j$('#error').show();  
                    j$('#error').html(event.message);
                }               
            }, 
            {escape: true}
        ); 
     }
</script>

APEX

@RemoteAction
global static pagereference loginAccount(String userName, String userpassword) {
    String UserId=null;
    List<Account> loginAccount = new List<Account>();
    try{
        loginAccount =[Select Id, password__c, email__c From Account Where email__c=: userName ];
    } catch (Exception e) { 
          throw  new RemoteVFException('qualcosa di innateso è successo');
    }

    if(loginAccount.size()==1){
        userId=loginAccount.get(0).id;
    } else if(loginAccount.size()==0) {
        throw  new RemoteVFException('nome o password non corretti');
    } else{
        throw  new RemoteVFException('qualcosa di innateso è successo');
    }
    return new PageReference('/TR/InsertTr?uid=' + UserId); 
}
2
  • 1
    Any errors in the debug log/javascript console? Aug 22, 2013 at 23:19
  • I can see that you have resolved the issue and the page is functional. What was the solution? Can you post your resolution steps or accept the given answer if it was accurate?
    – Mark Pond
    Aug 23, 2013 at 16:25

1 Answer 1

1

Your issue is because jQuery is not accessible to your Site user and all of the script in the page requires jQuery.

The error shown in the browser is:

Error: ReferenceError: jQuery is not defined Source File: http://trapptosemplify-developer-edition.eu2.force.com/TR/Login Line: 13

To resolve it, change the Cache Control setting on the Static Resource named MobileSample_Resources_jQueryMobile to Public. This will allow the Static Resource to be publicly visible.

1
  • Thk, it works... :D
    – Klodj_Meta
    Aug 26, 2013 at 8:19

You must log in to answer this question.

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