NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: Sibuya on May 27, 2016, 07:59:45 AM

Title: NT 9.09 receive Ajax Json and answer
Post by: Sibuya 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
Title: Re: NT 9.09 receive Ajax Json and answer
Post by: Bruce 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