+ Start a Discussion
bpl3792bpl3792 

actionFunction passing null to controller even though jQuery alert says there's a value

Passing an id from jquery to the actionfunction so it can do a page redirect. I had it working but for some reason it's not passing an id anymore, just a null. When I do alert(id); in the function being called, the alert comes up with the requested id. For some reaosn the id seems to get lost when going from jQuery to the action function. Any idea why this might be happening?

        j$('#Edit_Asset').live('click', function(){
            callActionMethod();

        });
        function callActionMethod(){
 
            pgRedirect_EditAsset(id);
        }
          
    });
   
</script> 

<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
</head>
<apex:form >
<apex:actionFunction name="pgRedirect_EditAsset" action="{!RedirectToEditAsset}" immediate="true">
    <apex:param name="IdParam" assignTo="{!AssetId}" value="" />
</apex:actionFunction>

 
Here's the apex

public String AssetId                               {get;set;} 
       public PageReference RedirectToEditAsset()
        {
            string url='/apex/AS_AssetEdit_m?id='+AssetId;
            PageReference pageRef = new PageReference(url);
           
           return pageRef;
            
        }

 

JHayes SDJHayes SD

Have you taken a look at the HTTP request that gets sent when the actionFunction is invoked?  Does it include the correct  variable/value?  In Chrome you can hit CTRL-SHIFT-I and select the Network tab to view the request.

bpl3792bpl3792

Since I'm just getting my feet wet with jQuery I'm not too familiar with using the debugger. I don't see how I could look at HTTP request, most of the pages don't exist once you click on them.
http://i.imgur.com/JAxLq.png
Here's a screenshot.