Jump to content

Asp and ajax errors


CarinaVB

Recommended Posts

Hello: I have an asp file thats builds an xml and retrieve database data, but it only works with Internet Explorer 6.1) The code of the principal.asp is: function connXML(url,vopt) { http_request = false; opt=vopt if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { http_request.overrideMimeType('text/xml'); } } else if (window.ActiveXObject) { // IE try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } if (!http_request) { alert('Giving up :) Cannot create an XMLHTTP instance'); return false; } http_request.onreadystatechange = alertContents; http_request.open('GET', url, true); http_request.send(null); } function alertContents() { if (http_request.readyState == 4) { if (http_request.status == 200) { var xmldoc = http_request.responseXML; switch (opt){ case "N": if (xmldoc0) {xmldoc = xmldoc0; xmldoc0=null} if (xmldoc.getElementsByTagName('RES').item(0).firstChild.data!="-1") { <% for each campo in split(v_campos,",") %> if(xmldoc.getElementsByTagName('<%= campo %>').item(0).firstChild) document.all.txt_<%= campo %>.value = xmldoc.getElementsByTagName('<%= campo %>').item(0).firstChild.data; else document.all.txt_<%= campo %>.value = ''; <% next %> } frame_detalle.location.href="parte_boleteria_detalles.asp?opt=N&id="+document.all.txt_ID_RECLAMO.value break; } else { alert('Ocurrio un Problema, Por Favor Ingrese Nuevamente'); } } }function Navegar(nav){ connXML(url,'N');}The error here is:Error: xmldoc.getElementsByTagName("RES").item(0) is null2) The asp wichs builds xml:principal_xml.asp<%Response.ContentType = "text/xml"%><%Set OBJdbConnection = Server.CreateObject("ADODB.Connection")OBJdbConnection.Open "Driver=SQL Server;Server=webserver\SQLEXPRESS;Initial Catalog=soporte;tRUSTED cONNECTION=No; User ID=sa; PWD=xxxxxxx"%><?xml version="1.0" encoding="iso-8859-1"?><%select case request.querystring("opt")case "N" strWHERE = "" strSQL = "" select case request.querystring("nav") case "P" 'PRIMERO strSQL = "SELECT min("&Session("v_id_tabla")&") as "&Session("v_id_tabla")&" from "&Session("v_tabla") case "A" 'ANTERIOR strSQL = "SELECT max("&Session("v_id_tabla")&") as "&Session("v_id_tabla")&" from "&Session("v_tabla")&" where "&Session("v_id_tabla")&" < '" & request.querystring("id") &"'" case "S" 'SIGUIENTE strSQL = "Select min("&Session("v_id_tabla")&") as "&Session("v_id_tabla")&" from "&Session("v_tabla")&" where "&Session("v_id_tabla")&" > '" & request.querystring("id") &"'" case "U" 'ULTIMO strSQL = "SELECT max("&Session("v_id_tabla")&") as "&Session("v_id_tabla")&" from "&Session("v_tabla")&"" case "B" 'BUSCAR strSQL = "'" & request.querystring("id") & "'" end select strSQL = "SELECT * FROM "&Session("v_tabla")&" where "&Session("v_id_tabla")&" in (" & strSQL &") ORDER BY "&Session("v_id_tabla")&"" 'response.write strSQL set rs=OBJdbConnection.execute(strSQL) %> <objetos> <% do while not rs.eof %> <objeto> <RES>1</RES> <% for i=0 to rs.fields.count -1 %> <<%= rs(i).name %>><%=rs(rs(i).name)%></<%= rs(i).name %>> <% next %> </objeto> <% rs.movenext loop %> <objeto> <RES>-1</RES> </objeto> </objetos> <% rs.close set rs=nothingThe error here is the line colored:Error: XML or text declaration in a place other than the entity principle<?xml version="1.0" encoding="iso-8859-1"?>3) The other problem is that when this page starts I have:document.all.btn9.click();window.focus();where btn9 is<img class="imgpointer" src="configuracion/images/mnu_ultimo.jpg" alt="Ultimo" onclick="Navegar('U')" name="btn9" id="btn9">The error here is:Error: document.all.btn9.click is not a functionAnybody has an idea?I search in the web but still can't resolve any of this errors....Regards

Link to comment
Share on other sites

I'm not sure about the XML errors, but for the button you should be referring to that by ID, not the dot notation. IE is the only thing that defines document.all. Use document.getElementById to refer to the element using its ID instead.

Link to comment
Share on other sites

That's right, events aren't defined on the elements like that. In order to be able to manually fire events in all browsers it will require a little work. This page has examples that show you how to add and remove events and fire them manually, both for browsers that support standards and also for IE:http://www.howtocreate.co.uk/tutorials/javascript/domeventsIt has a specific example of manually firing a click event. Scroll down to the section about manually firing events to see that.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...