TL;DR - I'd like to display the end result of a form submission in a popup overlay instead of a new tab.
I have a form that writes text on top of an image. I hit submit and it generates the image with the text embedded to it to a new page.
I am using this jQuery plugin for my popup overlay: http://dev.vast.com/jquery-popup-overlay/
To trigger the popup overlay, you have to assign a class to where you want the trigger. So I'll assign it to the form's submit button:
<input type="submit" value="Submit" class="my_popup_open">
I create a div with an id to show where I'd like the popup overlay to be at:
<div id="my_popup">CONTENT GOES HERE</div>
$(document).ready(function() {
$(".submit").click(function() {
var imageFile = $("input#imgInp").val();
var topLine= $("input#toptextbox").val();
var bottomLine = $("input#bottomtextbox").val();
var dataString = 'file-to-upload='+imageFile+'&firstname='+topLine+'&lastname='+bottomLine;
$.ajax({
type: "POST",
url: "action.php",
data: dataString,
success: function() {
// Initialize the plugin
$('#my_popup').popup();
}
});
return false;
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.rawgit.com/vast-engineering/jquery-popup-overlay/1.7.13/jquery.popupoverlay.js"></script>
<form action="">
First name:<br>
<input type='file' name="file-to-upload" id="imgInp">
<input type="text" name="firstname" id="toptextbox"><br> Last name:<br>
<input type="text" name="lastname" id="bottomtextbox><br><br>
<input type="submit" value="Submit" class="my_popup_open">
</form>
Recap question: So instead of opening a new page to action_page.php, how am I able to display the final result of the form within the popup overlay?