My VF page stops working when I have the following code inside the page. I am unable to figure out what is causing the errors.
function sendToCart() {
var skuSearch = name+" "+size+" "+amt+" "+flv;
var outSku;
<apex:form>
<apex:actionFunction name="getSkus" action="{!skuSearch}" rerender="outSku">
<apex:param name="skey" value = "skuSearch" assignto="{!skey}"/>
</apex:actionFunction>
</apex:form>
}
The corresponding apex class is as follows:
public class skuControl{
// The action function parameter gets set here - this is the input
public String skey {get; set;}
// The output is set here so it can be re-rendered into the page
public Product__C outSku {get; set;}
public PageReference skuSearch() {
// TODO why is this only returning on and anarbitrary one at that?
// Pass in the skey via a bind variable
List<Product__c> skus = [
select ItemSKU__c
from Product__c
where Description__c
LIKE :skey
];
// Pass out the value
outSku = skus[0];
return null;
}
}
EDIT: I updated the apex class to as below and I changed the JS function as above. I checked the debugger on my web browser and it gives the error:
SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data
Thanks in advance