NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started by: the_question on March 04, 2026, 10:58:54 AM
-
Hello,
Is there a way to tell NetTalk server not to send ajax data in response?
I have a browse, and I have created my event where response data are sent to my fetch() function request. Even when I use p_web.SendJSON(), it is wraped inside div.
...
<div id="contentbody_div" class=" nt-contentpanel nt-contentpanel-h">{"name":"John", "age":30, "car":null}</div>
...
I have tried with Accept parameters in request, but it is ignored by the server.
const response = await fetch("/BrowsePage?" + params, {
method: "GET",
headers: { Accept: "application/json" },
});
p_web.SendString() also gets wraped.
Is there a way to have response just with my data? I am using NetTalk 14.36 version.
-
I'm not sure you're asking the right question.
From your screen-shot I'm guessing you are writing custom JavaScript, which in turn makes a request to the server? And you've got custom code on the server to generate the response? But your custom JavaScript code doesn't match your custom response - or more accurately you don't feel you have enough control over the response to achieve what you are wanting to do?
Am I on the right track?
Bruce
-
Yes, I am creating custom JavaScript. And I just wanted to force the response from server to have my structure. Nothing default from NetTalk.
But, I have figure it out if I send in the request that ajax=1, instead 0, response is much smaller. And my text is in the beginning of the response. So I have modified code:
try {
const response = await fetch("/Link?" + params, {
method: "GET",
});
const text = await response.text();
const value = parseInt(text.slice(0, 1), 10);
return value;
} catch (e) {
console.info("Error GET /Link:", e);
return null;
}
With this, there is still some overhead, but is much smaller.