Thanks Gourav,

I have it working now and I can even understand it, which is even better.  
For anyone interested my revised working solution is below.

I'm sure it would be better practice putting the token into the headers as 
described in the documentation and elsewhere but I could not get it to work.


{% load static %}

<head>
<!-- <script src="{% static 'jquery-3.2.1.min.js' %}"></script> -->
<!-- <script src="static/jquery-3.2.1.min.js"></script> -->
<script src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js";></script>
</head>

<body>
{% csrf_token %}
<div>
<h1 id='hdr_1'>{{ hdr1 }}</h1>
</div>

<table>
<tr>
{% if my_apps_list %}
{% for my_apps in my_apps_list %}
<td>
<button type="button" id="app{{ forloop.counter }}">
<img src="{% static my_apps.app_icon %}" alt="{{ my_apps.app_name }}" height
="132" width="192">
</button><br><br>
<script>
$("#app{{ forloop.counter }}").click( function() {
document.getElementById('hdr_1').innerHTML = 'Hello World!';
$.ajax({
url : "{% url 'launch' %}",
type: "POST",
data: { csrfmiddlewaretoken: document.getElementsByName(
'csrfmiddlewaretoken')[0].value,
appname: '{{ my_apps.app_name }}',
apppath: '{{ my_apps.app_path }}',
appexe: '{{ my_apps.app_exe }}',
appargs: '{{ my_apps.app_args }}',
appusr: '{{ my_apps.app_user }}',
apppwd: '{{ my_apps.app_pwd }}',
applook4: '{{ my_apps.app_wait4 }}',
appdelay: '{{ my_apps.app_delay }}',
appkeys: '{{ my_apps.app_keys }}'},
dataType : "json",
success: function( msg ){
document.getElementById('appstatus').innerHTML = msg;
}
});
});
</script>
</td>
{% endfor %}
</tr>
</table>

<br>
<p id='appstatus'></p>

{% else %}
<p>No applications are available.</p>
{% endif %}

</body>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1bc91f14-bd24-4c84-929a-ad6302cf7709%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to