jQuery $.post() + IE8

前端 未结 4 651
面向向阳花
面向向阳花 2021-01-23 08:21
 


        
相关标签:
4条回答
  • 2021-01-23 09:02

    I figured it out. Im going to post the solution here in case it helps someone in future. The problem was with the url i was posting to. My url was a parameterised url and I was using a wrong syntax/format all along. The IE and non IE separation is not really needed. The answer lies in extracting the various components of the current url and pass it in $.post via the "data" array. Thanks for your inputs. Working code below:

    <script type="text/javascript" src="/scripts/jquery-1.6.2.min.js"></script> 
    <script type="text/javascript" src="/scripts/jquery.form.js"></script> 
    <script type="text/javascript" src="/scripts/jquery.url.js"></script>
    <script type="text/javascript"> 
    $(document).ready(function(){
    $("#SendReply").click(function(){                                      
    
        $(".error").hide();
        var hasError = false;
        var pathname = window.location.pathname;
        var random = Math.random();
        var kar_ = $.url.param("kar"); 
        var obj_ = $.url.param("obj");
        var me_ = $.url.param("me");
    
    
        var messageVal = $("#InquiryResponse").val();
    
    
    if(messageVal == 'Type your response in this space ...') {
        $("#InquiryResponse").after('<span class="error"><br><br><font color="red">You forgot to type your response to the inquiry. Please type it in the above space and submit again.</font><br></span>');
        hasError = true;
    }
    
    
    if(hasError == false) {
        $(this).hide();
    
        $.post( "inqdetails.asp",
            { Detail: messageVal, kar: kar_, obj: obj_, me: me_},
                function(data) {
    
                    $("#InqRespForm").slideUp("slow", function() {                 
                         $("#InqRespForm").before('<h1>Success</h1><p><font color="green">Your message has been sent.</font></p>');                             
    
                });
        });
    
    }
    
    return false;
    });                        
    });
    </script> 
    
    0 讨论(0)
  • 2021-01-23 09:02

    Why are you doing this: jQuery.browser.msie ????

    There is almost never a reason to detect the browser! And I can see absolutely nothing in your code that requires knowing what the browser is.

    0 讨论(0)
  • 2021-01-23 09:04

    Put this line within your HTML just after the <head> tag starts

    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    

    It will work for IE8+

    0 讨论(0)
  • 2021-01-23 09:13

    $.post( "", ... ) might have caused the problem. I found that it works in most browsers except IE.

    Rather use $.post(window.location, ... ) to post to the same page.

    0 讨论(0)
提交回复
热议问题