NetTalk Central

Author Topic: NT 9.09 receive Ajax Json and answer  (Read 3233 times)

Sibuya

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
    • Email
NT 9.09 receive Ajax Json and answer
« on: May 27, 2016, 07:59:45 AM »
Hi,

I'm working with a 3rd party JavaScript component that works with promises. So I have to receive an Ajax call with GET/POST with text or Json get data and I have to answer with text or Json too. Could anyone give me directions on how to get Ajax postings/data and how to answer?

Examples:

$.ajax({
    method: 'GET',
    url: '/SecwinLoginForm?parameter',
    success: onSuccess,
    error: onError
});

and

$.ajax({
    method: 'POST',
    url: '/SecwinLoginForm',
    data: JSON.stringfy({
        data1: parameter1,
        data2: parameter2
    }),
    contentType: 'application/json',
    success: onSuccess,
    error: onError
});

In WebHandler I try to get in ProcessGet but it does not enter in it.

Thank you.

Marcos

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: NT 9.09 receive Ajax Json and answer
« Reply #1 on: May 29, 2016, 11:57:36 PM »
Generally speaking I would suggest a NetWebServiceMethod using the "name" of the URL.
That has facilities for parsing incoming Json, and creating Json in response.

The URL is the MethodName.

Cheers
Bruce