Solved

How to handle IE8 popup after AJAX post call from jQuery UI dialog ?

Posted on 2014-12-08
6
260 Views
Last Modified: 2014-12-09
Hi I have put a form into a jquery UI dialog, after the user submits the form the data gets inserted into an MS SQL table and then I would like the dialog to close and the page to refresh showing the data that was just inserted.  When done in Internet Explorer 8 a warning box generated by the browser pops up saying 'To display the webpage again, the web browser needs to resend the information you've previously submitted' ...
I have tried different Javascript methods such as:
window.location='<%= ResolveUrl("Default.aspx") %>'
location.href = location.href    ~ (??? is this the correct usage and syntax ??? )~ nothing happens here

I've read about Post Redirect Get methods, but am having a hard time finding an example of how to implement this...
Would I put my $.ajax "Get" nested in the "POST" $.ajax function ?
...hope my question makes sense and I can provide more code if needed, but wanted to be as succinct as possible ...
$.ajax({
                    type: "POST",
                    url: "WebMethods.aspx/Insert1964",
                    data: '{insertcode: ' + JSON.stringify(insertcode) + '}',
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (response)
                    {                        

                        window.location.reload(true);
                        $(this).closest('.ui-dialog-content').dialog('close');

                   },
                    error: function (result) {
                        //alert("Error");
                        alert(result.responseText);
                    }
                });

Open in new window

0
Comment
Question by:Scarlett72
  • 3
  • 3
6 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40488564
why do you want to save your data using ajax instead using the Default.aspx page server side code ?
0
 

Author Comment

by:Scarlett72
ID: 40489008
Hi leakim, thank you for your suggestion, it has triggered a different method to fix this, however, if I do a server side insert, I will still have to refresh the page, it will still generate this pop up.  I'd like to try to find a way to do an ajax post and reload without having this popup generated ...
0
 
LVL 82

Expert Comment

by:leakim971
ID: 40489195
No, you don't a popup when posting
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:Scarlett72
ID: 40489484
Hi, following upwith the resolution to my issue raised in the GeekOut … I was able to resolve this by implementing the following:
function InsertCode() {
            
                var insertcode = {};
                insertcode.name = $("#lblAdminName").text();
                insertcode.pein = $("#lblAdminPein").text();
                insertcode.dte = $(".diagDte").text();
                insertcode.code = $("#ddlCodes").val();
                insertcode.duration = $("#ddlDuration").val();
                insertcode.getYear = $("#ddlYear").val();
                insertcode.getID = $("#tdID").val();
                alert(insertcode.getID);
                $.ajax({
                    type: "POST",
                    url: "WebMethods.aspx/Insert1964",
                    data: '{insertcode: ' + JSON.stringify(insertcode) + '}',
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (response)
                    {
                        {        
                           window.location.reload()  //…this was causing the pop up ... removed this line
                           $("#dialog-1").dialog('close');
    };
                    },
                    error: function (result) 
{
                        alert(result.responseText);
                    }                    
                });
                __doPostBack('', '');  //postback outside of ajax method ... added this
                return false;
            }
        }

Open in new window

0
 

Author Closing Comment

by:Scarlett72
ID: 40489489
Hi leakim, your answer wasn't the solution in the end, but you are correct that this is probably the wrong way to go about doing what I need to do, and will have to circle around the issue for a more efficient solution, but __doPostBack is working for me now.  Thank you for taking the time to respond...
0
 
LVL 82

Expert Comment

by:leakim971
ID: 40490057
you're welcome
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
cs.Designer Issue 2 19
Angular - filter - one works but other doesn't 13 25
Asp.net mvc 5 5 20
Birthdays 3 21
OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now