In my MVC application, I'm trying to populate two javascript variables before loading a script. But I keep getting the error that my variables aren;t set before the javascript file loads. I've been going in circles trying to figure this.
<script type="text/javascript">
$(document).ready(function () {
var applicationId = "@Constants.SquareUpPaymentInfo.AppID";
var locationId = "@Constants.SquareUpPaymentInfo.LocationID";
jQuery.getScript('https://js.squareup.com/v2/paymentform')
.done(function () {
jQuery.getScript('@Url.Content("~/Content/JS/sqpaymentform.js")')
.fail(function () {
alert('Failed');
})
})
.fail(
function () {
alert('There was a connection issue for the payment form library. ');
});
});
</script>
The sqpaymentform.js loads but it requires applicationID and locationID to be set but it thinks that they are not set for some reason but I can easily see that they are set in the chrome developer screen.
$(document).ready