[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 626
  • Last Modified:

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:
jquery:
                        $.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) {
                                        alert(jqXHR.responseText);
                                    } else {
                                        alert("Error! Try again...");
                                    }
                                }
                            });


vb.net
                    '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
0
Robert Treadwell
Asked:
Robert Treadwell
1 Solution
 
Luis PérezSoftware 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.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now