NetTalk Central

Author Topic: Reading values posted to page by JavaScript  (Read 2802 times)

olu

  • Sr. Member
  • ****
  • Posts: 352
    • View Profile
    • Email
Reading values posted to page by JavaScript
« on: July 07, 2024, 11:30:30 AM »
Got this JavaScript below that post two values as a json _KeyField_ and _TSK__Assignee to a page. Pls how do i read this values?

 
function assignMeToSelectedJob() {
        const selectedRowData = DataGrid.getSelectedRowsData();
        if (selectedRowData.length > 0) {
            const job = selectedRowData[0];
            const postData = {
                _KeyField_: job._KeyField_,
                _TSK__Assignee: "xkl10yVbynAjx5qGMcUM"  // Assuming this is the current user's ID
            };

            $.ajax({
                url: 'your-server-side-url-here',  // Replace with your server-side URL
                type: 'POST',
                contentType: 'application/json',
                data: JSON.stringify(postData),
                success: function (response) {
                    alert('Job assigned successfully!');
                    refreshDataGrid();
                },
                error: function (xhr, status, error) {
                    alert('Failed to assign job: ' + error);
                }
            });
        } else {
            alert('No job selected.');
        }
    }

osquiabro

  • Hero Member
  • *****
  • Posts: 687
    • View Profile
    • Email
Re: Reading values posted to page by JavaScript
« Reply #1 on: July 08, 2024, 04:04:51 AM »
you can put the result in session variable in your javascript like this

SetSessionValue('yoursessionname',yourvariable);

and then in webhandler in SessionValueSetFromBrowser

CASE p_Name
  OF 'yoursessionname'   
      IF p_web.gsv('yoursessionname')<>''
          Do yourroutine
      ELSE
          Do Cancel
      END     
END 

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Reading values posted to page by JavaScript
« Reply #2 on: July 08, 2024, 06:32:29 PM »
 the incoming payload is json. So you'd parse that out with a jFiles object.
the json string will be in p_web.GetValue('_json_')
You can process this in BrowseTasks procedure, since the URL part will take it into there.