We help IT Professionals succeed at work.
Get Started

AJAX how to return Null values

waf771
waf771 asked
on
459 Views
Last Modified: 2012-05-05
When using responseXML to return values from an asp document it will not return a NULL value or a blank value from the database without holding up the responseXML. How can I properly handle Null values without having to have somthing in the database field.  Right now I must have a value in the database field or the AJAX script does not complete the script. So how can  XML / AJAX ignore  the Nulls.

THE FOLLOWING IS THE AJAX:

function GetSystemEdit(SysID)
{
        
         xmlHttp = GetXmlHttpObject();
                       xmlHttp.onreadystatechange = ReturnGetSystem;
        xmlHttp.open('Get','EstimatesASP.asp?action=OpenSystem&SysID='+SysID, true);
        xmlHttp.send(null);
}


function ReturnGetSystem()
{

 if (xmlHttp.readyState == 4)
        {
             
            if (xmlHttp.status == 200)
          {
                    
                  var xmlDoc = xmlHttp.responseXML.documentElement;
                  
                  var System = xmlDoc.getElementsByTagName('System')[0].childNodes[0].nodeValue;
                  var DateEntered = xmlDoc.getElementsByTagName('DateEntered')[0].childNodes[0].nodeValue;
                var EnteredBy = xmlDoc.getElementsByTagName('EnteredBy')[0].childNodes[0].nodeValue;
                  var Notes = xmlDoc.getElementsByTagName('Notes')[0].childNodes[0].nodeValue;
                  var RCSNotes = xmlDoc.getElementsByTagName('RCSNotes')[0].childNodes[0].nodeValue;
                  var TaxRate = xmlDoc.getElementsByTagName('TaxRate')[0].childNodes[0].nodeValue;
                  var MU = xmlDoc.getElementsByTagName('MU')[0].childNodes[0].nodeValue;
                  var SysID = xmlDoc.getElementsByTagName('SysID')[0].childNodes[0].nodeValue;
                  

         }
             else
             {
            alert('There was a problem with the request.');
         }
      }
        
}







THE FOLLOWING IS THE ASP CODE:

Dim EstID
Dim XML
Dim System
Dim DateEntered
Dim EnteredBy
Dim TaxRate
Dim MU


SysID = CStr(Request.QueryString("SysID"))


XML = ""
     

      SQL = "SELECT * FROM Systems WHERE SystemID = "&SysID
      set rs=Server.CreateObject("ADODB.Recordset")
      rs.Open SQL, REDconnstring
      
      
      XML = XML + "<root>"      
      XML = XML + "<System>"&rs("System")&"</System>"
      XML = XML + "<DateEntered>"&rs("DateEntered")&"</DateEntered>"
      XML = XML + "<EnteredBy>"&rs("EnteredBy")&"</EnteredBy>"
      XML = XML + "<Notes>"&rs("Notes")&"</Notes>"
      XML = XML + "<RCSNotes>"&rs("RCSNotes")&"</RCSNotes>"
      'XML = XML + "<DateBid>"&rs("DateBid")&"</DateBid>"
      'XML = XML + "<DateWon>"&rs("DateWon")&"</DateWon>"
      XML = XML + "<TaxRate>"&rs("TaxRate")&"</TaxRate>"
      XML = XML + "<MU>"&rs("MU")&"</MU>"
      XML = XML + "<SysID>"&SysID&"</SysID>"
                     XML = XML + "</root>"


      
    set rs = nothing
      response.ContentType = "text/xml"
      response.Write(XML)




.
Comment
Watch Question
CERTIFIED EXPERT
Expert of the Year 2008
Top Expert 2008
Commented:
This problem has been solved!
Unlock 1 Answer and 9 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE