I have problem with getting value from ajax to asp. I have form with select input field and if I select one option (from select options). I want to change my form action tag value.
$(document).ready(function() {
$("#preLin").change(function(){
if ($('#preLin option:selected').val() === "Test" ) {
var actionTag = "printHosp.his";
$.ajax({
type: "POST",
url: "http://local:8001/Default.his",
data: {actionTag: "test.asp"},
success: function(data) {
alert(actionTag);}
});
});
ASP
dim actionTag
actionTag = Request.form("actionTag")
<form action="<%=actionTag%>" name="input" method="post" target="_blank">
<select name="preLin" id="preLin">
<optgroup >
<option value="Test"></option>
<option value=""></option>
</optgroup>
</form>
There's best practices to do what you want, but i suggest you to solve this problem by adding a "ajax error function", then analyzing the responseText
.
Change your ajax call for something like:
$.ajax({
type: "POST",
url: "http://eli.local:8001/priemimas/Default.his",
data: {actionTag: "test.asp"},
success: function(data) {alert(actionTag);},
error: function(xhr) {alert(xhr.responseText);}
});