简体   繁体   中英

returing data after the call success, ajax?

'function makeRequest() 
 {
var G_REL_URL="'||owa_util.get_cgi_env('SCRIPT_NAME')||'" 
   var v_data_sales ={ pvCurrCd:"'||CURRDEF||'"
            };       
 $.ajax({
 url:G_REL_URL+ "/contr_entry_pkg.SELECT_SALES_CENTERS",
 data:v_data_sales,
 async:false,        
success: function(vRetVal){
  //var jsonObj =  eval("("+vRetVal+")");
function processresponse(v_data_sales,vRetVal)

               }

               });
          } '||CHR(10)||     
       'function processresponse (v_data_sales,vRetVal){
retJson=eval("("+vRetVal+")");
} '; 

i want to return a data to a dropdown after there is a onchange='makeRequest" im not sure if im doing it the right way but is not giving me any errors and is not working maybe my logic is wrong but after its success if calls the function processresponse so it will return pvcurrcd but its not doing it. any help or tips ,thanks

here below is where it make the onchange call which i dont think it matter here

 HTP.P('<td class="reqlabel1">Sales Center:</td>');
        HTP.P('<td class="tablelabel">');
         HTP.P(Get_Sc_Dd(PVNAME=>'pnSalesCenterID', PVORAID=> VUSERNAME, 
PVDEFVAL => NSALESCENTERID, PVEVENT=>'class="reqinput1" onChange="makeRequest();" style="width:260px"'));

it will change the currency dropdown here

    HTP.P('<td class="reqlabel1">Currency:</td>');
        HTP.P('<td class="tablelabel">');
         HTP.P(Get_Currency_Dd(PVNAME=>'pvCurrCd', PVDEFVAL => NULL, 
PVEVENT=>'class="reqinput1" id="pvCurrDd" onblur="makeRequest();"  style="width:200px"'));

your code is missing some correct syntax... try this

'function makeRequest(){
        var G_REL_URL="'||owa_util.get_cgi_env('SCRIPT_NAME')||'";
        var v_data_sales ={ pvCurrCd:"'||CURRDEF||'"         };       
        $.ajax({
            url:G_REL_URL+ "/contr_entry_pkg.SELECT_SALES_CENTERS",
            data:v_data_sales,
            async:false,        
            success: function(vRetVal){
                //var jsonObj =  eval("("+vRetVal+")");
                            /*
                                fire up the Javascript console in 
                                chrome/firefox/safari
                                and look at the result of:
                            */
                            console.log(vRetVal);
                            // or better:
                            console.dir(vRetVal);

                processresponse(v_data_sales,vRetVal);
            }
        });
        function processresponse(v_data_sales,vRetVal){
            retJson=eval("("+vRetVal+")");
        }
 }'; 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM