Reputation: 31
I need to do ajax to javascript and get a result by calling js function. but I cannot get data.
I'm making TIZEN web application. and I have web service on my server(asp). I did ajax to my web but I got error. As you can see, I Tried to debugging through console.log but any reasonable values not printed.
app.js (90) :getAlarmData()
app.js (153) :
$.ajax({
type: "POST"
, url: "serverIP/WebProject/WebContents/view/filename/function name"
, data: null
, contentType: "application/json; charset=utf-8"
, dataType: "json"
, async: false
, success: function (jSonResult) {
},
error: function (xhr, status, error) {
console.log(error + "\n" + status + "\n" + xhr.responseText);
}
});
app.js (90) :getAlarmData()
app.js (153) :
Upvotes: 2
Views: 158
Reputation: 289
You are trying to do a function call on a file which is present on your server, you can't do that directly. You have to open a road on your server which return the result of your function.
You have to take look about communicate a single page application (SPA - Front end app) and your API (server side app).
For example :
$.ajax({
type: "POST"
, url: "serverIP/my/awesome/road/which/calling/my/function"
, data: null
, contentType: "application/json; charset=utf-8"
, dataType: "json"
, async: false
, success: function (jSonResult) {
console.log( jSonResult );
},
error: function (xhr, status, error) {
console.log(error + "\n" + status + "\n" + xhr.responseText);
}
});
For resume, you have to :
Upvotes: 1