Ajax, Success: returning msg or data to the success function

Posted on 2012-09-21
Last Modified: 2012-10-22
I have a jquery ui dialog box containing a iframe.  When user presses the Submit button I want to process user entry and depending on the entry either close dialog and return to parent page, or redirect iframe to another iframe.

My questions:
1.  Can to send data back to the success parameter?  ie.  success: function(data) {  
2.  If yes, then how.
3.  If no, is there a way of redirecting the contents in dialog ui without closing and reopening.

See Code below:
                        $.ajax({ type: 'POST',
                                url: ajaxUrl,
                                data: '{divName:"' + divName + '", signInID:"' + signInID + '", signInOutType:"In", orgID:' + orgID + '}',
                                contentType: "application/json; charset=utf-8",
                                dataType: "json",
                                success: function (data) {
                                    if (data.?) {
                                        //How do I do this properly?
                                error: function (jqXHR, error, errorThrown) {
                                    if (jqXHR.status && jqXHR.status == 400) {
                                    } else {
                                        alert("Error! Try again...");
                    'Get SignInType
                    Dim sitQuery = (From sit In oDB.OrgSignInTypes Where sit.orgID = orgID And sit.fieldValue = "Alpha-Numeric Entry" And sit.selectFlag = "True" _
                                    Or sit.fieldValue = "Numeric Only Entry" And sit.selectFlag = "True"
                                    Select sit).SingleOrDefault
                    If (sitQuery Is Nothing) Then
                        Return False
                        Exit Function
                    End If
                    'Redirect iframe based on Query_FieldValue
                    If sitQuery.fieldValue = "Alpha-Numeric Entry" Then
                        'Send data back to jqueryUI to redirect to Alpha-Numeric page

                    ElseIf sitQuery.fieldValue = "Numeric Only Entry" Then
                        'Send data back to jqueryUI to redirect to Numeric page

                    End If
Question by:Robert Treadwell
    1 Comment
    LVL 25

    Accepted Solution

    Try this:
    If sitQuery.fieldValue = "Alpha-Numeric Entry" Then
        Return "url_that_i_want_to_go_to"
    ElseIf sitQuery.fieldValue = "Numeric Only Entry" Then
        Return "another_url_that_i_want_to_go_to"

    And in javascript:
    success: function (data) {
        document.location = data.d; //or document.location.href = data.d

    Hope that helps.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
    In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    761 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

    13 Experts available now in Live!

    Get 1:1 Help Now