Need help. I have a page called edit.php. I am trying to send a javascript variable to a modal window that contains php, so that I can run a query to pull data. I don't have much experience with ajax, and I couldn't find a good tutorial for this.
Here is my javascript code with an attempted ajax call:
<script type="application/javascript">
$(document).on("click", ".open-EditRow", function () {
var myGroupId = $(this).data('id');
$(".modal-body #groupId").val( myGroupId );
// ajax call
var url = "" + myGroupId;
$.get(url, function(data){
// do something here
});
});
</script>
I know I need to create a separate folder with a file that will convert myGroupId into a PHP variable.
Here is the modal that the myGroupId should be returned to:
<div class="modal hide fade" id="myEditModal" tabindex="-1" role="dialog" aria-labelleby="myModalLabel" aria-hidden="true">
<div class="modal-body">
<form class="well-small" action="" method="POST" id="modalForm" name="modalForm">
<?php
// here is where I need myGroupId returned to
?>
</form>
</div>
</div>
Can anyone give me an example of how that separate file should look and how to send it back to the modal on my edit.php file?
Thank you in advance.