Someone could help me with a little piece of javascript code ? I'm trying to develope a little webapp, but I'm in trouble with simple communication from a modal to his parent window :( I'm using jquery, bootstrap, bootstrap.datetimepicker and bootstrap.validator1000hz.
I have to call a function from parent window with 'sendData' input field as parameter so I need to grab the value of 'sendData' from the modal. Submit button is correctly disabled until user input the required date (because Validator plug-in) but when I click on it modal disappear end nothing is printed to console. Thanks in advance !
This is my modal
<!-- Modal -->
<div id="modalPrint" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Seleziona intervallo di stampa</h4>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<div class="form-group">
<label>Indicare la data d'invio</label>
<div class='input-group date col-sm-3' id='sendData' data-date-format="DD/MM/YYYY">
<input type='text' class="form-control" required >
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
<div class="help-block with-errors"></div>
</div>
<button type="submit" id="print" class="btn btn-default btn-sm pull-right" data-dismiss="modal">
<span class="glyphicon glyphicon-print"></span>
<span style="font-size:smaller;">Stampa</span>
</button>
</div>
</form>
<div class="modal-footer">
</div>
</div>
</div>
</div>
<script>
$('#modalPrint').validator().on('submit', function () {
console.log('ok')
});
</script>
In Modal You can use this :
Then define SendData function in your js like this :
Update :
jquery ajax is an asynchronous HTTP (Ajax) request. it sends data while your page doesn't start any post back to server. here is an ajax call with jquery:
as an another exmaple you can see below:
which Calls a local script on the server /api/getWeather with the query parameter zipcode=97201 and replace the element #weather-temp's html with the returned text to show status to user on page.
if you are using php the echo on the page will send as result , if you use asp.net the Response.Write Method writes the result and give it back to you. Please see the picture below:
So in url paramter of data object in ajax call , you will set the url of page which will process your request.
So you need add this script in top of your page:
or you can download jquery and put it near of your project files and reference them :
for reading more about jquery ajax , please visit here: https://learn.jquery.com/ajax/key-concepts/