It took three hours to check and find that the returned header information of the page was changed.
When application/x-javascript is added, ie8 will not work.
If it is text/html, it is OK, or if it is not specified.
Is it a bug? Let me greet the ie developers who wrote this code.
Ajax header information, encoding seems to have to pay attention to it.
How to submit form data using ajax
Url parameter submissions
Copy codeThe Code is as follows: <script type = "text/javascript" src = "../js/jquery. js"> </script>
<Script type = "text/javascript">
Function checkCorpID () // checks whether the customer ID is available
{
If ($. trim ($ ("# txtF_CORPID") [0]. value) = "") // txtF_CORPID is the customer ID input box
{
Alert ("Enter the customer ID! ");
}
Else
{
$ ("# CheckFlag" ..html ("detecting"); // display the prompt information
$. Ajax ({
Type: "get ",
Url: "CheckCorpID. ashx ",
Data: "ID =" + $. trim ($ ("# txtF_CORPID") [0]. value), // submit a form, equivalent to CheckCorpID. ashx? ID = XXX
Success: function (msg) {$ ("# checkFlag" ).html (""); alert (msg) ;}// the operation after the operation is successful! Msg is the value passed from the background.
});
}
}
</Script>
Ii. Front-end code for Form to submit data:
CodeCopy codeThe Code is as follows: <script type = "text/javascript" src = "../js/jquery. js"> </script> // must be referenced
<Script type = "text/javascript" src = "../js/jquery. form. js"> </script> // must be referenced
<Script type = "text/javascript">
// Wait for the DOM to be loaded
$ (Document). ready (function ()
{
$ ('# Tip'). hide (); // The elements that display the operation prompt are invisible.
$ ('# Form1'). submit (function () // submit the form
{
// Alert ("ddd ");
Var options = {
Target: '# Tip', // the backend will assign the passed value to this element.
Url: 'returnvisit. aspx? Flag = do ', // to which execution is submitted
Type: 'post ',
Success: function () {alert ($ ('# Tip'). text ();} // displays the operation prompt
};
$ ('# Form1'). ajaxSubmit (options );
Return false; // in order not to refresh the page, false is returned. It has been executed in the background. It's okay!
});
}
);
</Script>