views:

39

answers:

2

Hi

I am facing an issue here as shown in code is mentioned below

Inside the function I have something like this

AJAXRequest("getActivityEntries?orgEntry="+orgentryid+"&activity_entry="+activity_entry+"&target=AJAX");

if orgentryid is null here,

After building the HTML page, the JAVAScript looks like…

AJAXRequest("getActivityEntries?orgEntry="++"&activity_entry="+$activity_entry+"&target=AJAX");

Firefox throws and exception with ++ being used with Strings.

Then we added If/Else checks for the existence of orgentryid…

if(activity_entry && "activity_entry" != " ")
            if (orgentryid)
                    AJAXRequest("getActivityEntries?orgEntry="+orgentryid+"&activity_entry="+activity_entry+"&target=AJAX");
                else
                    AJAXRequest("getActivityEntries?activity_entry="+activity_entry+"&target=AJAX");

        else
          if (orgentryid)
             AJAXRequest("getActivityEntries?orgEntry="+!orgentryid+"&target=AJAX");
           else
             AJAXRequest("getActivityEntries?target=AJAX");

But since then performance has taken a beating. Is there anything can be done with Firefox.

+1  A: 

Have you tried something like this ?

AJAXRequest("getActivityEntries?orgEntry="+(orgentryid||"")+"&activity_entry="+(activity_entry||"")+"&target=AJAX");
Golmote
Take care if `orgentryid` might be an integer with value `0`, as this will not work. If `orgentryid` is known to be a string, you'll be OK.
Tim
The if/else code used by the author seems to indicate that both `orgentryid` and `activity_entry` are strings ;)But I didn't check for `activity_entry!=" "` ... but this should not cause any error.
Golmote
+4  A: 

Pragmatic without ternary operators - assuming strings and not 0's in the vars

var URL = "getActivityEntries?target=AJAX"; 
if (activity_entry) URL += "&activity_entry="+activity_entry;
if (orgentryid)     URL += "&orgEntry="+orgentryid;
AJAXRequest(URL);
mplungjan