Autor Zpráva
dehtak
Profil
tak jsem udelal podle teto stranky http://www.dhtmlgoodies.com/index.html?whichScript=ajax_chained_select
chaine selct jenze je tu problem
sice to funguje , ale ne pod operou a nezobrazuje se mi dialektika misto ni se mi zobrazi otaznik
peta
Profil
dialektika?
diakritika?

co treba nastaveni kodovani v:
- ajax -
// if (req.overrideMimeType!=null) {req.overrideMimeType('text/xml; charset=UTF-8');} //XML+charset
// z.setRequestHeader('Content-type','application/x-www-form-urlencode d; charset=UTF-8'); //+charset

- php - header()
- sql - SET NAMES
- html
" <meta http-equiv="content-type" content="text/html; charset=windows-1250"/>",

jinak bych doporucil pouzivat textresponse misto xml, protoze to se da lepe nastavovat.
dehtak
Profil
ano ja jsem koukal do toho ajax scriptu a oni to tam prave maj nejak osetreny proti znakum
hodim sem ten script on je trosku delsi , mozna by to chtelo neco odstranit nebo ten script predelat
mam pocit ze to dela ta funkce encodeURLstring ale kdyz jsem dal false , tak to bylo porad stejny
/////////////////////////////////////////////////// AJAX.JS////////////////////////////////////////////////////////////

function sack(file) {
this.xmlhttp = null;

this.resetData = function() {
this.method = "POST";
this.queryStringSeparator = "?";
this.argumentSeparator = "&";
this.URLString = "";
this.encodeURIString = true;
this.execute = false;
this.element = null;
this.elementObj = null;
this.requestFile = file;
this.vars = new Object();
this.responseStatus = new Array(2);
};

this.resetFunctions = function() {
this.onLoading = function() { };
this.onLoaded = function() { };
this.onInteractive = function() { };
this.onCompletion = function() { };
this.onError = function() { };
this.onFail = function() { };
};

this.reset = function() {
this.resetFunctions();
this.resetData();
};

this.createAJAX = function() {
try {
this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e1) {
try {
this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
this.xmlhttp = null;
}
}

if (! this.xmlhttp) {
if (typeof XMLHttpRequest != "undefined") {
this.xmlhttp = new XMLHttpRequest();
} else {
this.failed = true;
}
}
};

this.setVar = function(name, value){
this.vars[name] = Array(value, false);
};

this.encVar = function(name, value, returnvars) {
if (true == returnvars) {
return Array(encodeURIComponent(name), encodeURIComponent(value));
} else {
this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);
}
}

this.processURLString = function(string, encode) {
encoded = encodeURIComponent(this.argumentSeparator);
regexp = new RegExp(this.argumentSeparator + "|" + encoded);
varArray = string.split(regexp);
for (i = 0; i < varArray.length; i++){
urlVars = varArray[i].split("=");
if (true == encode){
this.encVar(urlVars[0], urlVars[1]);
} else {
this.setVar(urlVars[0], urlVars[1]);
}
}
}

this.createURLString = function(urlstring) {
if (this.encodeURIString && this.URLString.length) {
this.processURLString(this.URLString, true);
}

if (urlstring) {
if (this.URLString.length) {
this.URLString += this.argumentSeparator + urlstring;
} else {
this.URLString = urlstring;
}
}

// prevents caching of URLString
this.setVar("rndval", new Date().getTime());

urlstringtemp = new Array();
for (key in this.vars) {
if (false == this.vars[key][1] && true == this.encodeURIString) {
encoded = this.encVar(key, this.vars[key][0], true);
delete this.vars[key];
this.vars[encoded[0]] = Array(encoded[1], true);
key = encoded[0];
}

urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];
}
if (urlstring){
this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);
} else {
this.URLString += urlstringtemp.join(this.argumentSeparator);
}
}

this.runResponse = function() {
eval(this.response);
}

this.runAJAX = function(urlstring) {
if (this.failed) {
this.onFail();
} else {
this.createURLString(urlstring);
if (this.element) {
this.elementObj = document.getElementById(this.element);
}
if (this.xmlhttp) {
var self = this;
if (this.method == "GET") {
totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString;
this.xmlhttp.open(this.method, totalurlstring, true);
} else {
this.xmlhttp.open(this.method, this.requestFile, true);
try {
this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
} catch (e) { }
}

this.xmlhttp.onreadystatechange = function() {
switch (self.xmlhttp.readyState) {
case 1:
self.onLoading();
break;
case 2:
self.onLoaded();
break;
case 3:
self.onInteractive();
break;
case 4:
self.response = self.xmlhttp.responseText;
self.responseXML = self.xmlhttp.responseXML;
self.responseStatus[0] = self.xmlhttp.status;
self.responseStatus[1] = self.xmlhttp.statusText;

if (self.execute) {
self.runResponse();
}

if (self.elementObj) {
elemNodeName = self.elementObj.nodeName;
elemNodeName.toLowerCase();
if (elemNodeName == "input"
|| elemNodeName == "select"
|| elemNodeName == "option"
|| elemNodeName == "textarea") {
self.elementObj.value = self.response;
} else {
self.elementObj.innerHTML = self.response;
}
}
if (self.responseStatus[0] == "200") {
self.onCompletion();
} else {
self.onError();
}

self.URLString = "";
break;
}
};

this.xmlhttp.send(this.URLString);
}
}
};

this.reset();
this.createAJAX();
}

////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Tady je ten php soubor s temi mesty , ja ho ale mam upravenej ze mi to cte z databaze
<?php

............................................. Conection mysql mam tady
if(isset($_GET['ortCode'])){
................................. vypis mysql {

echo "obj.options[obj.options.length] = new Option('$jmeno','$id');

$jmeno je option select - takto mi to zobrazuje pak v select
$id je value

}
}
?>

///////////////////////////////////////////////////////////////////// //////////////////////////////////
nepisu sem cely php to je jen aby jste to pochopily.
////////////////////////////////////////////////////////////////////// //////////////////////////////////
a tady je ten index.html kde se zobrazuji ty select pole
<head>

<meta http-equiv="content-type" content="text/html; charset=windows-1250"/>
</head>
<script type="text/javascript" src="ajax.js"></script>
<script type="text/javascript">
var ajax = new sack();

function getCityList(sel)
{
var ortCode = sel.options[sel.selectedIndex].value;
document.getElementById('dhtmlgoodies_city').options.length = 0; // Empty city select box
if(ortCode.length>0){
ajax.requestFile = 'getCities.php?ortCode='+ortCode; // Specifying which file to get
ajax.onCompletion = createCities; // Specify function that will be executed after file has been found
ajax.runAJAX(); // Execute AJAX function
}
}

function createCities()
{
var obj = document.getElementById('dhtmlgoodies_city');
eval(ajax.response); // Executing the response from Ajax as Javascript code
}


</script>

<form action="" method="post">

<select id="dhtmlgoodies_country" name="dhtmlgoodies_country" onchange="getCityList(this)">
<option value="">Select</option>
<option value="dk">Denmark</option>
<option value="no">Norway</option>
<option value="us">US</option>
</select><select id="dhtmlgoodies_city" name="dhtmlgoodies_city"></select>
zde muzou byt dalsi select s jinou id ..........................
</form>

problem je ze kdyz hodim do toho souboru php <head> charset windows at.... </head>
tak mi pak ten script nefunguje . Jinak je to dobrej script protoze s nim muzu klidne udelat i deset select poli
jen ta cestina me stve
peta
Profil
Mi to prijde jako bezcenna smes scriptu. Dej odkaz na tvoji stranku, kde je mozne to otestovat nebo rekni, co ti napise JS konzola. Kazdy www prohlizec ma JS konzolu.

Jinak plati, co jsem psal:
- ajax -
// if (req.overrideMimeType!=null) {req.overrideMimeType('text/xml; charset=UTF-8');} //XML+charset
// z.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=UTF-8'); //+charset
- php - header()
- sql - SET NAMES
- html
" <meta http-equiv="content-type" content="text/html; charset=windows-1250"/>",

Si to vyzkousej. Do php souboru plati php hlavicky, do js plati js, pro mysql sql, pro html kod html hlavicky. Jinymi slovy, mozna by pomohlo, kdybys do PHP odpovedi pridal header() s prislusnymi parametry. Kazdopadne cizi script neni tvuj a mozna mas jinou chybu.
luka
Profil *
dehtak

Tenscript je dobry a tam netreba menit nic. Daj len do php na zaciatok header("Content-Type: text/html; charset=windows-1250"); a hlavne petu nepocuvaj.

peta

Nic proti ale tebe tu vzdy nieco chyba. Napr. cent vie dat vseobecnu odpoved aj bez scriptu ale peta potrebuje script. A ked tu ma script http://www.twilightuniverse.com/ ta mu chyba zase nieco ine nakoniec das odkaz na svoju stranku a to je cela tvoja rada. nezda sa ti to uz tu trapne? Ale jasne ty si to nejako odvovodnis
dehtak
Profil
Dej odkaz na tvoji stranku, kde je mozne to otestovat nebo rekni, co ti napise JS konzola.
tady to je http://sylt.homedns.org:81/server/modules/buchung/index.php ale jak rikam ten script nefunguje pokud je v tom php souboru head skousel jsem i do toho ajaxu davat ten charset , furt to nefunguje
dehtak
Profil
skript stahnete tady http://www.villa-sylt.de/01.zip
je to udelany bez databaze , ale ten php jde predelat a normalne to jede z databaze , jen ty otazniky mne ......
uz jsem z toho na prasky skousim to uz tejden
peta
Profil
luka
Nechapes zakladni vec. JS se dela tak, ze mas otevrenou JS konzolu a sledujes chyby. A kdyz clovek neni schopen vypsat, jake mu to pise chyby, tak ja vysledek konzoly mohu ziskat jedine tak, ze si vyklikam jeho stranku.
Jakym zpusobem delas JS ty? Velice rad se poucim.
Centi do tohoto fora nepsal, nevim, jak to s timto tematem souvisi. Proc asi? Nechape problem, nenapise ani dotaz na podrobnosti. Nema cas resit, kdyz pisatel neni schopen dodat potrebne informace.

Pokud to spravne chapu, tak je problem s hacky a carky. A jak uz jsem psal, problem muze byt na tecto mistech:
- server nastaveni
- html meta
- js - php - header
- html - php- header
A aby bylo mozne neco z toho vyloucit, je treba videt, co dela ten jeho priklad.
Prijde mi zbytecne ztracet cas a programovat za nej zadarmo a spravne. Mne by to chodilo.

dehtak
http://sylt.homedns.org:81/server/modules/buchung/index.php
Nefunguje mi odkaz
http://www.villa-sylt.de/01.zip
to mi jede, ale nevim, zda mi to k necemu bude, kdyz pro simulaci musim vytvorit X souboru a databazi a to se mi asi nebude chtit, ze?

Treba, ja mam takovyto chat, nevim, zda mam cestinu vyresenou uplne, ale muzes otestovat.
http://peter-mlich.wz.cz/programs/machat/machat.htm
http://www.volny.cz/peter.mlich/programs/machat/chatminiAjax.rar

Ajax odesilas na "getCities.php"
- v "getCities.php" nikde nevidim funkci s nazvem header, cili spolehas na to, ze ti server nastavi sam spravne kodovani. A co kdyz ma jine?
- Z databaze nic netahas, databazi lze vyloucit.
- getCities.php?ortCode='+ortCod , kdyby to nebylo cislo, tak by tady mohlo byt take spatne kodovani, funkce escape/ - PHP erlencode

Vaše odpověď

Mohlo by se hodit

Neumíte-li správně určit příčinu chyby, vkládejte odkazy na živé ukázky.
Užíváte-li nějakou cizí knihovnu, ukažte odpovídajícím, kde jste ji vzali.

Užitečné odkazy:

Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm:

0