Last active
July 29, 2019 08:29
-
-
Save hellt/93154da758722192beca0fdf80d53b3a to your computer and use it in GitHub Desktop.
javascript portion of the pycatjify web service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function () { | |
$('#convert_btn').click(function () { | |
var data = {} // object to hold the user input data | |
// store user data in a data["pycatj_data"] | |
if ($('#yaml_switch').prop("checked")) { | |
data["pycatj_data"] = $('#in_form').val() // in case of YAML data - store it as a string | |
} else { | |
data["pycatj_data"] = JSON.parse($('#in_form').val()) // in case of JSON data - store it as an object | |
} | |
// todo: add root input element | |
// data["root"] = "POST" | |
console.log(data) | |
var body = JSON.stringify(data) | |
$.ajax({ | |
url: "https://us-central1-pycatj.cloudfunctions.net/pycatjify", | |
contentType: "application/json", | |
data: body, | |
dataType: "json", | |
type: 'POST', | |
success: function (response) { | |
$('#out_form').val(response.data) | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment