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

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
Robert TreadwellManaging DirectorAsked:
Who is Participating?
Luis PérezConnect With a Mentor Software Architect in .NetCommented:
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.