Search code examples
javascriptpagemethods

return doesnot work with pagemethods


I wonder how to return a value using page methods. the following code gives me error

function main()
{
PageMethods.custref(ddlpf.options[ddlpf.selectedIndex].value,custref1.value,custSuc,custErr);

function custSuc(boo)
{
if(boo==true)
{message("Cust ref already exists");btn_enable(false);make_null();return;}
}
function custErr(){}
Pagemethods.set("true",suc,err);
function suc(res){//code}
function err(){}
}

my problem is even the message displayed, "set" pagemethod is working


Solution

  • change it as the following

    function main()
    {
    PageMethods.custref(ddlpf.options[ddlpf.selectedIndex].value,custref1.value,custSuc,custErr);
    
    function custSuc(boo)
    {
    if(boo==true)
    {message("Cust ref already exists");btn_enable(false);make_null();return;}
    
    Pagemethods.set("true",suc,err);
    function suc(res){//code}
    function err(){}
    }
    function custErr(){}
    }