Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get two parameter from javascript
#1
How get all parameters if you click button? My code get only first paramater!

javascript:
var index1 = 0;
var index2 = 1;

function SelectIndex1() {
  return index1.toString();   
}

function SelectIndex2() {
  return index2.toString();   
}

code:
procedure MyButtontAsyncClick ...
begin
AddToInitProc('ajaxCall("ReceiveIndex1", "&ID=" + SelectIndex1();');

  RegisterCallBack('ReceiveIndex1',
        procedure (aParams: TStrings)
        begin
            MapIndex:= StrToIntDef(aParams.Values['ID'],0);
            AddToInitProc('GetMap(' + MapIndex +')');
        end
);

AddToInitProc('ajaxCall("ReceiveIndex2", "&ID=" + SelectIndex2();');

RegisterCallBack('ReceiveIndex2',
procedure (aParams: TStrings)
begin
ListIndex:= StrToIntDef(aParams.Values['ID'],0);
AddToInitProc('GetList(' + ListIndex +')');
end
);
end;
Reply
#2
When calling your application via Ajax (Async) you should send everything in a single call (unless your response triggers another server call, which is useful in some cases, but it's not that common).

Can you send both in the same call or do you need the second call to follow the first (call and response)?
Reply
#3
BTW, it's better to execute JavaScript directly

WebApplication.CallbackResponse.AddJavaScriptToExecuteAsDATA('ajaxCall("ReceiveIndex1", "&ID=" + SelectIndex1();');
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)