Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JAVAX problem with special parameter

Status
Not open for further replies.

celia05es

Programmer
Jan 10, 2002
81
US
Hello,
I am using the following JAVAX stuff:
Code:
....
[COLOR=red][plist="cname="+fieldName+"&cvalue="+cvalue;
 
[b]url="update_field.jsp?"+plist;[/b]
makeRequest(url);[/color]
}

function makeRequest(url)
{
  http_request = false;
  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("Msxml2.XMLHTTP");
      }
      catch (e)
      {
        try
        {
          http_request = new ActiveXObject
        } catch (e) {}
      }
    }
  }

  if (!http_request)
  {
     alert('Giving up. Cannot connect');
     return false;
  }
  http_request.onreadystatechange = alertContents;
  http_request.open('GET', url, true);
  http_request.send(null);
}


function alertContents()
{
  if (http_request.readyState == 4)  // COMPLETE
  {
    if (http_request.status == 200)
    {
      var values = http_request.responseText;
      var ier=trim(values);
      if (ier != "0")
      {
        alert(ier);
      }
    }
    else
    {
       alert("Problem with the request.\nTry it again.\nIf the problem persists,
 consult the database administrator");
    }
  }
}

The problem arises when the cvalue parameter is a special character like "%" or "#" => I get a http_request.status =500

How can I solve this problem?

Thank you





 
It does work!!! You are the best. Thank you so much!

By the way, I am having problem with the AJAX code with Explorer.... sometimes it does not work correctly. I mean that I receive a http_request = 200 (completed) but I know that the .jsp file is not called !!! Strange hey!
I have been told that I could fix the problem forcing the IE to repaint... is this true ? If so, how should I do it?

 
forcing the IE to repaint

If you mean refresh the page, then this would work:

Code:
location.reload(true);

If you want to force the browser to reshow the current content without getting it again from the server, I imagine you'd have to do something like:

1. Hide all content (see below),
2. Wait a small amount of time to guarantee it was hidden,
3. Re-show all content.

The hiding can be done like this:

Code:
document.getElementsByTagName('body')[0].style.display = 'none';

and the showing by using "block" instead of "none".

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thanks for the response.
Where should I put the above code?

 
Actually, are you aware of this king of problem with Explorer?
I mean when using JAVAX?
Sometimes, though the http_request.status is 200 (which should mean that the request has been completed)... the file has not been called!!!
I know that because the called file write into a debug file and there is nothing.

THe problem is that is does not always happens!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top