Minor declaration fix

scope of $primarykeyvalue extended to whole function for it to be
defined when it is set as a data attribute, ajax still fails