Quick background: Very new to web development. I have a bootstrap page with a form which users can fill out. There are four fields (two text boxes, one radio, one dropdown). The idea was to form a JSON using that input data and POST it to my HTTP server, but it doesn't seem to be working anymore.
Very strange, my code was working perfectly a few hours ago (have been testing with requestb.in). Now all of a sudden it (1) only sends the POST if I have long values for the apiname and apiurl variables, and (2) no longer sees what I've chosen from the radio checkboxes (env1 - env3), and instead always thinks I've chosen 'Dev,' regardless of what was actually selected. I'm assuming my issues are caused by the jQuery in my code and not the HTML, so I've attached that here:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"> </script>
<script>
$(document).ready(function(){
$("button").click(function(){
var env1 = document.getElementById("seldevid");
var env2 = document.getElementById("selstageid");
var env3 = document.getElementById("selprodid");
var apiname = $("#apinameid").val();
var apiurl = $("#apiurlid").val();
var actionvar;
$("#actionid").change(function() {
actionvar = $(this).val();
}).change();
if (env1.checked = true) {
var env = "Dev";
} else if (env2.checked = true) {
var env = "Stage";
} else if (env3.checked = true) {
var env = "Prod";
}
$.post("http://requestb.in/107fmof1",
{
apiName: apiname,
apiURL: apiurl,
environment: env,
action: actionvar
},
function(data,status){
alert("Data: " + data + "\nStatus: " + status);
});
});
});
</script>
Thanks for the help!