I wanna send form data to test.html by using asynchronous communication. I wrote in index.html
<body>
<form method="post" action="">
<select id="mainDD" data-placeholder="Choose" class="chzn-select" style="width:600px;">
{% for i in json_data.items.values %}
<option value="{{forloop.counter}}">{{ i }}</option>
{% endfor %}
</select>
{% for key, values in preprocessed %}
<select name="type" id=type{{forloop.counter}}>
{% for counter, value in values %}
<option value="{{forloop.counter}}">{{ value }}</option>
{% endfor %}
</select>
{% endfor %}
</form>
<script type="text/javascript">
$(document).ready(function () {
$('#mainDD').on('change', function() {
var thisType = "type" + $(this).val();
for(i=1; i<6; i++) {
var thisId = "type" + i;
if(thisType !== thisId) {
$("#"+thisId).hide();
}
else {
$("#"+thisId).show();
}
}
}).trigger('change');
});
</script>
<form id="postform" action="http://localhost:8000/app/test_view" method="POST">
{% csrf_token %}
<input type="submit" value="SEND">
</form>
<script type="text/javascript">
$('[name=type]').change(function() {
var array1 = [];
var array2 =[];
$('[name=main] option:selected').each(function() {
array1 = $(this).text();
console.log(array1);
});
$('[name=type] option:selected').each(function() {
array2 = $(this).text();
console.log(array2);
});
});
$.ajax({
url: 'test.html',
dataType: 'html',
timeout:3000,
async: true,
success: function(html) {
$('.newsarea').html(html).fadeIn(5000);
},
error: function() {
alert('Error');
}
});
</script>
</body>
I wanna send selected i & value's variables to test.html.Now when I put send button,nothing is shown in test.html. I wrote test.html like
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>RESULT</title>
</head>
<body>
<h2>TOPIC</h2>
<div class="newsarea">
</div>
</body>
</html>
I wanna show selected i & value's values in this place of .What is wrong in my code?How can I fix this?
test.html? How do you know thattest.htmlis being visited by user? - guest271314test.htmlvisited by user? - guest271314