I have successfully created a simple WebApp written in HTML / javascript which is hosted on the ignition gateway via the WebDev module.
I have used ajax GET and POST methods in the WebApp to talk to SQL tables via python resources.
What i am trying to do now is be able to write a GET / POST script in python resource that will allow me to read and write Ignition tags from the WebApp.
I tried a basic example of sending a tagPath string from the WebApp and tried reading the tag and sending the value back. But ran into the issue of not being able to pass “/” as part of a tagPath variable in an ajax GET method.
What is the best way to properly expose tags to a web interface?
Here is the example i have tried, hardcoding the tagPath into the python resource directly (still doesn’t work).
Javascript code in WebApp:
function.getTag(tagPath){
formData = {"tagPath": tagPath};
$.ajax({
type: "GET",
url: "../python/tag",
data: formData,
success: function(result){
console.log(result);
},
error: function(){
console.log("Error with getTag function");
},
contentType: "application/x-www-form-urlencoded"
});
}
Python GET method Code in Ignition WebDev module ‘tag’ resource:
def doGet(request, session):
import system
#tagPath = request['params']['tagPath']
#tagVal = system.tag.read('temp/'+tagPath).value
tagVal = system.tag.read('temp/testMemReal').value
return {'json': system.util.jsonEncode(tagVal)}