🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.lang.javascript
3 messages
3 total messages Started by narskitom Fri, 17 Feb 2012 13:49
Walidacja skryput w3c
#51026
Author: narskitom
Date: Fri, 17 Feb 2012 13:49
94 lines
4398 bytes
Mam w sekcji <head> wstawiony taki oto skrypt:

<script type="text/javascript">
 function getAjaX(func,str)
 {
 if (str=="")
   {
   document.getElementById("txtHint").innerHTML="";
   return;
   }
 if (window.XMLHttpRequest)
   {// code for IE7+, Firefox, Chrome, Opera, Safari
   xmlhttp=new XMLHttpRequest();
   }
 else
   {// code for IE6, IE5
   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }
 xmlhttp.onreadystatechange=function()
   {
   if (xmlhttp.readyState==4 && xmlhttp.status==200)
     {
 
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
     }
   }
 xmlhttp.open("GET","ajax.php?f="+func+"&q="+str,true);
 xmlhttp.send();
 }
 </script>

o problem z walidatorem w3c, który wyświetla błędy:

Line 59, Column 42: cannot generate system identifier for general
entity "q"
 xmlhttp.open("GET","ajax.php?f="+func+"&q="+str,true);

✉

 An entity reference was found in the document, but there is no
reference by that name defined. Often this is caused by misspelling
the reference name, unencoded ampersands, or by leaving off the
trailing semicolon (;). The most common cause of this error is
unencoded ampersands in URLs as described by the WDG in "Ampersands in
URLs".

 Entity references start with an ampersand (&) and end with a
semicolon (;). If you want to use a literal ampersand in your document
you must encode it as "&amp;" (even inside URLs!). Be careful to end
entity references with a semicolon or your entity reference may get
interpreted in connection with the following text. Also keep in mind
that named entity references are case-sensitive; &Aelig; and &aelig;
are different characters.

 If this error appears in some markup generated by PHP's session
handling code, this article has explanations and solutions to your
problem.

 Note that in most documents, errors related to entity references will
trigger up to 5 separate messages from the Validator. Usually these
will all disappear when the original problem is fixed.
 Line 59, Column 42: general entity "q" not defined and no default
entity
 xmlhttp.open("GET","ajax.php?f="+func+"&q="+str,true);

✉

 This is usually a cascading error caused by a an undefined entity
reference or use of an unencoded ampersand (&) in an URL or body text.
See the previous message for further details.
 Line 59, Column 43: reference not terminated by REFC delimiter
 xmlhttp.open("GET","ajax.php?f="+func+"&q="+str,true);

✉

 If you meant to include an entity that starts with "&", then you
should terminate it with ";". Another reason for this error message is
that you inadvertently created an entity by failing to escape an "&"
character just before this text.
 Line 59, Column 43: reference to entity "q" for which no system
identifier could be generated
 xmlhttp.open("GET","ajax.php?f="+func+"&q="+str,true);

✉

 This is usually a cascading error caused by a an undefined entity
reference or use of an unencoded ampersand (&) in an URL or body text.
See the previous message for further details.
 Line 59, Column 41: entity was defined here
 xmlhttp.open("GET","ajax.php?f="+func+"&q="+str,true);


czy mógłym prosić o pomoc co może być nie tak bo wydaje się wszystko
ok ale błędy są. Z góry dziękuję za pomoc
Re: Walidacja skryput w3c
#51027
Author: NotBear
Date: Fri, 17 Feb 2012 15:49
19 lines
1465 bytes
W dniu 2012-02-17 14:49, narskitom@yahoo.pl pisze:
> czy mógłym prosić o pomoc co może być nie tak bo wydaje się wszystko
> ok ale błędy są. Z góry dziękuję za pomoc

Walidator napotkal ciag "&q" i uznal, ze to niedokonczona encja - bez 
srednika. Nie omieszkal o tym poinformowac w dosc rozwlekly sposob.

Poinformuj go za pomoca zakomentowanego CDATA, ze ma nie szukac w tresci 
skryptu znacznikow.
<script type="text/javascript">
//<![CDATA[
   Tu twoj skrypt
//]]>
</script>

A najlepiej wyrzuc JS do osobnego pliku.

-- 
NotBear
Re: Walidacja skryput w3c
#51028
Author: porneL
Date: Fri, 17 Feb 2012 21:38
48 lines
2196 bytes
On Fri, 17 Feb 2012 13:49:23 -0000, <narskitom@yahoo.pl> wrote:

> Mam w sekcji <head> wstawiony taki oto skrypt:
>
> <script type="text/javascript">
>  function getAjaX(func,str)
>  {
>  if (str=="")
>    {
>    document.getElementById("txtHint").innerHTML="";
>    return;
>    }
>  if (window.XMLHttpRequest)
>    {// code for IE7+, Firefox, Chrome, Opera, Safari
>    xmlhttp=new XMLHttpRequest();
>    }
>  else
>    {// code for IE6, IE5
>    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
>    }
>  xmlhttp.onreadystatechange=function()
>    {
>    if (xmlhttp.readyState==4 && xmlhttp.status==200)
>      {
> document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
>      }
>    }
>  xmlhttp.open("GET","ajax.php?f="+func+"&q="+str,true);
>  xmlhttp.send();
>  }
>  </script>
>
> o problem z walidatorem w3c, który wyświetla błędy:
>
> Line 59, Column 42: cannot generate system identifier for general
> entity "q"
>  xmlhttp.open("GET","ajax.php?f="+func+"&q="+str,true);
>

1. Skrypt jest w porządku, to DOCTYPE masz zły. Nie zawracaj sobie głowy  
XHTML, bo i tak ci nie działa: http://pornel.net/xhtml . Użyj walidatora  
HTML5, to dostaniesz informacje o błędach, które mają większe znaczenie.

2. Użyj jakiejś biblioteki, bo to obciach po raz milionowy pisać "na  
piechotę" wszystkie obejścia do AJAX-a.

-- 
regards, porneL
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads