473,486 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How can i do a comparison on responseHTML/responseText?

19 New Member
I have an ajax call that looks like this:
Expand|Select|Wrap|Line Numbers
  1.              jQuery.ajax({
  2.                  type: "GET",
  3.                  url: '/configaudit-portlet/audit_App2App_list.jsp',
  4.                  dataType: "text",
  5.                  data: map,
  6.                  global: true,
  7.                  success: function(responseText){
  8.                      if(responseText == ""){
  9.                          createJvmTable();
  10.                      }else{
  11.                         document.getElementById("audit_form_window").style.width = '765px';
  12.                         document.getElementById("audit_form_window").style.height = '375px';
  13.                         document.getElementById("main_window").style.width = '745px';
  14.                         document.getElementById("main_window").style.height = '360px';
  15.                          document.getElementById("app2app1_app_name").innerHTML = getAuditApp();
  16.                          document.getElementById("app2app2_app_name").innerHTML = getAuditApp();
  17.                          document.getElementById("app_row").style.visibility = 'visible';
  18.                          document.getElementById("audit_app2app_table_div").innerHTML = responseText;
  19. .
  20. .
  21. .
  22. };
  23.  
The page that is called returns either a html/text for a table or an empty string. My problem is that when i am checking if the empty string is returned it it fails the if statement and always performs the else statement. Is there a better way to do this comparison?
Apr 27 '11 #1
3 3950
JKing
1,206 Recognized Expert Top Contributor
Are you positive an empty string is being returned? Check to see if null or undefined are being returned.
Apr 27 '11 #2
Dormilich
8,658 Recognized Expert Moderator Expert
Check to see if null or undefined are being returned.
that wouldn’t matter as there is no type-safe comparison made (i.e. false = "" = 0 = null = undefined)

nevertheless, doing a check what is returned is necessary.
Apr 28 '11 #3
JKing
1,206 Recognized Expert Top Contributor
Ah yes, forgot javascript only does type comparison using ===. Thanks for pointing that out.
Apr 28 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
5547
by: fochie | last post by:
Greetings, I'm having a problem when I try to GET a file from my server via xmlhttp when using Mozilla. With IE I can get any type of file fine, get/display headers fine, etc. With Mozilla,...
3
3542
by: e271828 | last post by:
I'm trying to access the source of an HTML page with as few alterations from the actual source (as in, that seen from the View Source option) as I can. The method...
5
8841
by: furby | last post by:
I have this little bit of code : var request = false; var divid = 0; var fforie; try { request = new XMLHttpRequest(); fforie = "FF"; } catch (trymicrosoft) { try { //request = new...
6
7785
by: mihirnmehta | last post by:
This is my code function getDetails() { var name = document.getElementById("movie_name").value; if (window.XMLHttpRequest) //For Mozilla Browsers { XMLHttp=new XMLHttpRequest() }
1
4268
by: KAS | last post by:
First of all, I am very much a newbie... From what I have read, it seems to me that both of these should be filled in all the time. The responseXML being a DOM representation and the responseText...
4
5075
by: -Lost | last post by:
For example: var newlines = 'a\n\nb\n\nc'; alert(newlines); Yet, if I get that *exact* same line from an XMLHttpRequest's responseText, it is always alerted as: a\n\nb\n\nc
1
8987
by: farghal | last post by:
Hello as many people I'm new to ajax but trying my best to understand. At this point I got a problem I'm not able to solve. I've looked on several forums and googled internet but I can't find a...
6
3124
by: lazukars | last post by:
Hi, I am attempting an ajax request. I am using PHP serverside. Below is what the response text should be. ajaxRequest.responseText ="{username_is_taken : "This username has been taken",}" ...
5
6614
by: wendallsan | last post by:
Hi all, I'm running into a situation where it seems that JS stops executing as soon as I call an eval in my script. I have an Ajax.Request call to a PHP page that builds a JS object and returns...
4
2522
RamananKalirajan
by: RamananKalirajan | last post by:
Hi All, I am using Ajax inorder to retrieve a data from the db which is an xml and i am parsing the responseText into an xml. the code what i had tried is working well with IE, but the...
0
7105
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7180
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7341
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5439
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4870
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3076
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1381
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.