After easyui form Ajax submit, the system prompts the solution for downloading content in IE.

Source: Internet
Author: User

 

When the easyui form plug-in is used in IE to create or edit data (A Piece Of JSON is returned after the operation is successful), the callback function cannot be run, but the download content is prompted.
The prompt in ie9 is as follows: To solve this problem, you must return the JSON string to the client in the following format.

<Body>
<PRE> {"message": "saved successfully", "data": NULL, "success": true} </PRE>
</Body>

So I wrote an hack method:

 

View code 1 ///   <Summary>
2 /// Unified response class for front-end Ajax requests
3 ///   </Summary>
4 Public Class Ajaxresult
5 {
6 Private Ajaxresult ()
7 {
8 }
9
10 Private Bool _ Iserror = False ;
11
12 ///   <Summary>
13 /// Error?
14 ///   </Summary>
15 Public Bool Iserror { Get { Return _ Iserror ;}}
16
17 ///   <Summary>
18 /// Error message or success message
19 ///   </Summary>
20 Public String Message { Get ; Set ;}
21
22 ///   <Summary>
23 /// Data returned when the request is successful or failed
24 ///   </Summary>
25 Public Object Data { Get ; Set ;}
26
27 ///   <Summary>
28 /// Indicates what operations should be performed on the front-end
29 ///   </Summary>
30 Public String Action { Get ; Set ;}
31
32 # Region Error
33 Public Static Ajaxresult error ()
34 {
35 Return New Ajaxresult ()
36 {
37 _ Iserror = True
38 };
39 }
40 Public Static Ajaxresult error ( String Message)
41 {
42 Return New Ajaxresult ()
43 {
44 _ Iserror = True ,
45 Message = message
46 };
47 }
48 # Endregion
49
50 # Region Success
51 Public Static Ajaxresult success ()
52 {
53 Return New Ajaxresult ()
54 {
55 _ Iserror = False
56 };
57 }
58 Public Static Ajaxresult success ( String Message)
59 {
60 Return New Ajaxresult ()
61 {
62 _ Iserror = False ,
63 Message = message
64 };
65 }
66 Public Static Ajaxresult success ( Object Data)
67 {
68 Return New Ajaxresult ()
69 {
70 _ Iserror = False ,
71 Data = Data
72 };
73 }
74 Public Static Ajaxresult success ( String Message, Object Data)
75 {
76 Return New Ajaxresult ()
77 {
78 _ Iserror = False ,
79 Data = data,
80 Message = message
81 };
82 }
83 # Endregion
84
85 Public Override String Tostring ()
86 {
87 Return New Javascriptserializer (). serialize ( This );
88 }
89
90 /* When using form Ajax submit, the server response shocould be an HTML file with a textarea element or a pre element. The response data shocould be inside the textarea element or pre element. For example:
91 <Body>
92 <PRE> {"message": "saved successfully", "data": NULL, "success": true} </PRE>
93 </Body>
94 To retrieve the response data:
95 $ ('# Ff'). Form ({
96 Success: function (data ){
97 Alert (data );
98 }
99 });
100 */
101 Public Actionresult toactionresult ()
102 {
103 VaR Result = New Contentresult ();
104 Result. content = String . Format ( " <Body> <PRE> {0} </PRE> </body> " , This . Tostring ());
105 Result. contenttype = " Text/html " ;
106 Return Result;
107 }
108 }

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.