Reputation: 31
I want to generate a popup after an ajax call. My current code (below) creates a new tab and not alert box.
$.ajax
({
type: "POST",
url: "addDayData.php",
data: TblData,
async: false,
success: function (data) {
window.open("addnewexcursion.php");
}
});
What should I change to allow the new content to appear in a popup rather than a new tab?
Upvotes: 0
Views: 4647
Reputation: 35
How to create a simple popup with ajax content? for that we need little bit of css,some js and html. Its very simple.First add a div with class popup_box,add the div into outside of the main wrapper class. we need some styling for the popup so use the css with this. You can add/modify your own things into it. Then the main thing the js. Add these functions loadPopupBox ()and unloadPopupBox()(definitions are given below). call them at appropriate occasions, that’s it.done! complete code and style are given below.
Upvotes: 0
Reputation: 1
Well you can use colorbox( http://www.jacklmoore.com/colorbox/ ) for popup and pass your url in href as parameter. Or you can append your own popup as in
var resp=jQuery.ajax({url:"www.whatever.com"}).done(function(resp){jQuery('body').append("<div class="popup">"+resp+"</div>");});
Of course you have style your popup with position as fixed and fade the background.
Upvotes: 0
Reputation: 430
Better to open a 'html form in popup': On success $( "#dialog-form" ).dialog( "open" );
Upvotes: 3
Reputation:
Try this
newwindow=window.open('addnewexcursion.php','name','height=200,width=150');
if (window.focus) {newwindow.focus()}
return false;
Instead of just
window.open("addnewexcursion.php");
Refer this link
Upvotes: 0
Reputation: 3096
to open new pop-up use
window.open('www.yourUrl.com','name','height=200,width=150')
specify width and height for window.open
, this will open up a new pop-up window.
NOTE : Pop-ups are subjected to be blocked based on browser's configuration
Upvotes: 0
Reputation: 8476
you should check for other window.open
parameter
$.ajax({
type: "POST",
url: "addDayData.php",
data: TblData,
async: false,
success: function (data) {
window.open("addnewexcursion.php", "myWindow","width=200,height=100");
}
});
Upvotes: 0
Reputation: 11717
you should use alert()
instead of window.open()
$.ajax
({
type: "POST",
url: "addDayData.php",
data: TblData,
async: false,
success: function (data) {
alert("POPUP");
}
});
Upvotes: 1