Non-refresh display data - XMLHTTP application

xiaoxiao2021-03-06  32

When the front, the supervisor asked if he did not have a refresh display data, and there was no answer to the question. It feels very simple, and the JS operation XMLDOCOMENT is displayed on the page. Post code, welcome to guide:) ---------------------------------------- --------- Test.aspx.vb ------------------------------------ --------- private sub page_load (Byval e as system.EventArgs) Handles mybase.load 'Place the user code of the initialization page here

If Not (Me.Request ("State") IS Nothing, the first time, XMLHTTP has not passed directly to DIM DS AS NEW DATASET Me.Da.selectCommand.commandText = "Select * from" me. Request ( "state"). ToString Me.Da.Fill (Ds) Dim writer As New XmlTextWriter (Response.OutputStream, Response.ContentEncoding) writer.Formatting = Formatting.Indented writer.Indentation = 4 writer.IndentChar = "" Ds. Writexml (Writer) 'Write DS's data to XML Writer.flush () response.end () Writer.close () end if End Sub ------------------- --------------------- Test.aspX -------------------------- ---------------- <% @ page language = "VB" autoeventwireup = "false" codebehind = "test.aspx.vb" inherits = "norefresh.test"%> Norefresh </ title> <meta content = "Microsoft Visual Studio .NET 7.1" Name = "Generator" > <Meta content = "Visual Basic .NET 7.1" Name = "Code_Langu AGE "> <meta content =" JavaScript "name =" vs_defaultClientScript "> <meta content =" http://schemas.microsoft.com/intellisense/ie5 "name =" vs_targetSchema "> <script> function load (state) { VAR OXMLHTTP = New ActiveXObject ("msxml2.xmlhttp"); var odoc = new activXObject ("msxml2.domdocument"); oxmlhttp.open ("post", "test.aspx? state =" state, false; oxmlhttp. Send (""); result =</p> <p>oXMLHTTP.responseText; oDoc.loadXML (result); var field = document.all ( "TxtField") value;. var field2 = document.all ( "TxtField2") value;. maxNum_out = oDoc.getElementsByTagName (field) .length; Document.all ("tdtitle"). Innerhtml = field; document.all ("tdtitle2"). InnerHtml = Field2; Document.all ("TD1"). InnerHTML = ""; Document.all ("TD2"). InnerHtml = ""; For (i = 0; i <maxnum_out; i ) {str1 = odoc.get.GtelementsBytagname (field) .Item (i) .text; str2 = odoc.getlementsBytagname (Field2) .Item (i) .text; document; document; document; document; .all ("TD1"). InnerHTML = STR1 "<br>"; Document.all ("TD2"). InnerHTML = STR2 "<briPt> </ head> <body ms_positioning =" GridLayout "> <form id =" form1 "method =" post "runat =" server "> <font face =" Song body "> <ask: textbox id =" txtsql "style =" z-index: 101; left: 18px Position: Absolute; Top: 22px "Runat =" server "tooltip =" SQL Hare! "Height =" 26px "Width =" 560px "> Authors </ asp: textbox> <input style =" z-index: 102; Left: 472px; width: 99px; position: absolute; top: 56px Height: 26px "οNCLICK =" "TYPE =" Button "value =" go "> <table id = Table1" style = "z-index: 103; Left: 16px; width: 544px; Position: absolute; top: 104px; Height: 190px "cellspacing =" 1 "cellpadding =" 1 "width =" 544 "border =" 1 "> <</p> <p>Tr> <TD ID = "TDTITLE" style = "width: 166px; height: 33px"> </ td> <td = "tdtitle2" style = "height: 33px"> </ td> </ tr> <TR > <TD ID = "TD1" style = "width: 166px"> </ td> <td id = "td2"> </ td> </ tr> </ table> <ask: textbox id = "txtfield" style = "Z-index: 104; Left: 16px; position: absolute; top: 56px" Runat = "server" tooltip = "Field Hare!" Height = "25px" width = "79px"> city </ asp: textbox> <ask: textBox ID = "txtfield2" style = "z-index: 106; Left: 104px; position: absolute; top: 56px" runat = "server" height = "24px" width = "80px"> AU_FNAME </ asp : TextBox> </ font> </ form> </ body> </ html> This example is very simple, then try to use JS to put the client's XmLDocument Send to the server, then read Dataset, want to bind directly to DataGrid, but Failure, the code is as follows, I hope that the expert is one or two ------------------------------------- --Test.aspx.vb ------------------------------------ Private Sub Page_load (Byval Sender AS System.Object, ByVal e as system.eventargs Handles mybase.load 'Place the user code of the initialization page here</p> <p>IF not (Me.Request ("State") IS Nothing) The Dim DS As New DataSet Me.da.selectCommand.commandtext = "Select * from" me.Request ("State"). Tostring me.da.fill Ds) Dim writer As New XmlTextWriter (Response.OutputStream, Response.ContentEncoding) writer.Formatting = Formatting.Indented writer.Indentation = 4 writer.IndentChar = "" Ds.WriteXml (writer) writer.Flush () Response.End () Writer.close () end if if not (Me.Request ("ISXML") IS Nothing) THEN DIM DS1 AS New DataSet DS1.Readxml (Me.Request.InputStream) Me.DataGrid1.datasource = DS1.TABLES (0). Default1.databind () end if End sub ---------------------------------------------------------------------------------------------------------------------------------- -------- Test.aspx --------------------------------- <% @ Page Language = "vb" autoeventwireup = "false" code "codebehind =" test.aspx.vb "inherits =" norefresh.test "%> <! Doctype html public" - // W3C // DTD HTML 4.0 Transitional // En "> <html> <head> <title> Norefresh </ title> <meta content =" Microsoft Visual Studio .NET 7.1 "Name =" Generator "> <meta content = "Visual Basic .NET 7.1" name = "CODE_LANGUAGE"> <meta content = "JavaScript" name = "vs_defaultClientScript"> <meta content = "http://schemas.microsoft.com/intellisense/ie5" name = "vs_targetSchema > <Script> function load (state) {var oxmlhttp = new activXObject ("msxml2.xmlhttp");</p> <p>VAR ODOC = New ActiveXObject ("msxml2.domdocument"); oxmlhttp.Open ("post", "test.aspx? state =" state, false); oxmlhttp.send ("); result = oxmlhttp.responsext; ODOC .loadXML (Result); Document.all ("textXML"). Value = odoc.xml; var sxml = odoc.xml; var oxmlhttp2 = new activXObject ("msxml2.xmlhttp"); oxmlhttp2.open ("post", " TEST.ASPX? ISXML = YES ", false); oxmlhttp2.send (sxml);} </ script> </ head> <body ms_positioning =" gridLayout> <form id = "form1" method = "post" runat = "Server"> <font face = "Song Body"> <ask: TEXTBOX ID = "txtsql" style = "z-index: 101; left: 18px; position: absolute; top: 22px" runat = "tool" tooltip = " SQL HARE! "Height =" 26px "Width =" 560px "> authors </ ask: TEXTBOX> <input style =" z-Index: 102; Left: 472px; width: 99px; position: absolute; top: 56px; height : 26px "οnclick =" "ο" "type =" but "value =" go "> <Table ID =" Table1 "style =" z-index: 103; Left: 16px; width: 544px; position: Absolute; Top: 104px; Height: 190px "Cellspacing =" 1 "CE Llpadding = "1" width = "544" border = "1"> <tr> <td = "tdtitle" style = "width: 166px; height: 33px"> </ td> <TD ID = "TDTITLE2" Style = "HEIGHT: 33PX"> </ td> </ tr> <tr> <TD ID = "TD1" style = "width: 166px"> <</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-62728.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="62728" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.043</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'I3IpI1wbnsMKyBX_2B7mGZIsaXfKgUR3h5Owh1YT5Ai5_2FBxYDdH74fMHy37OxklIUGDhIQqcQTnGnBCycngNdHzA_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>