Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hi all,
 
I am using the script below but it s not redirecting the page.
 
string rdpConnect = "function btnShowID_onclick(){" +
            "if(document.getElementById('MainContent_ctl00_txtBeginDateID').value!='' && document.getElementById('MainContent_ctl00_txtEndDateID').value!='' && document.getElementById('MainContent_ctl00_ddlAuditorsID').value!='' )" +
            "{" +
                    //"alert($('#ContentPlaceHolder1_ucSample_txtName').val());" +
                "$.ajax({type: 'POST'," +
                "url: '~/WebService.asmx/Navigatetopage'," +
                "data:  '{zip:jhg}'," +
                "contentType: 'application/json; charset=utf-8'," +
                "dataType: 'json'," +
                "success: function(msg) {" +
                    "if(msg.d=='True'){" +
                            //"window.location.href='~/ReportPage/ReportViewerForAll.aspx?&ReportName=" + _reportName + "';" +
                            "window.location.href='Default.aspx'"+
                        "}" +
                    "}" +
                 "});" +
              "}" +
 
            "else" +
            "{" +
                "alert('Please Enter The Required Field(s)');" +
                "return false;" +
            "}" +
            "}";
 

                rdpFunctions.InnerHtml = rdpConnect;
                this.Controls.Add(rdpFunctions);
                flag = false;
            }
 

Any idea or help is higly appreciated.
Thanks in advance
 
Shafik
Posted 8-Jan-13 5:10am
Shafik481
Edited 8-Jan-13 5:20am
Keith Barrow137.7K
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

What if the condition is true, but the ajax call isn't a succes? This would not show. Try to add code for the error situation, like this:
$.ajax({
    url: ...,
    data: ...,
    dataType: 'json',
    type: 'POST',
    timeout: 10000,
    success: function(json){
      //some code
    },
    error: function(jqXHR, textStatus, errorThrown){
      //some code
    }
 });
 
Good luck!
  Permalink  
Comments
Shafik at 8-Jan-13 12:39pm
   
Thanks for your Anser 1000 times. Now my code lool loke below: function btnShowID_onclick() { if(document.getElementById('MainContent_ctl00_txtBeginDateID').value!='' && document.getElementById('MainContent_ctl00_txtEndDateID').value!='' && document.getElementById('MainContent_ctl00_ddlAuditorsID').value!='') { $.ajax({ url: '~/WebService.asmx/Navigatetopage', data: '{zip:jhg}', dataType: 'json', type: 'POST', timeout: 10000, success: function(json) { window.location.href='Default.aspx'; return true; }, error: function(jqXHR, textStatus, errorThrown) { alert('Please Enter The Required Field(s)'); return false; } }); } } But stil i am getting only error message.its not going to default.aspx Can you plz tell me where i suppose to change my code. Thanks Shafik
E.F. Nijboer at 14-Jan-13 8:39am
   
Have you looked at the parameters of the error function? They should give you more info about what is going on.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Shai Vashdi 480
1 Tadit Dash 305
2 Sergey Alexandrovich Kryukov 250
3 Peter Leow 190
4 OriginalGriff 163
0 Sergey Alexandrovich Kryukov 9,435
1 OriginalGriff 5,498
2 Peter Leow 4,230
3 Maciej Los 3,540
4 Abhinav S 3,353


Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 8 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid