Recommend this page to a friend! |
pAjax | > | All threads | > | Problems | > | (Un) Subscribe thread alerts |
|
![]() Hello, thanks for the great class. I'm learning so much about Ajax from your class.
Now i have some problems. First problem : please see following codes. It's submitting to itself. note action="<?=$PHP_SELF?>". if you press "submit" button. the error will be occured. see the errors bellow. Warning: Invalid argument supplied for foreach() in /home/httpd/vhosts/ahkorea.de/httpdocs/_share/_shareAjax/class.pAjaxParser.php on line 8 Warning: Cannot modify header information - headers already sent by (output started at /home/httpd/vhosts/ahkorea.de/httpdocs/_share/_shareAjax/class.pAjaxParser.php:8) in /home/httpd/vhosts/ahkorea.de/httpdocs/_share/_shareAjax/class.pAjax.php on line 101 Fatal error: Unknown PHP Type while parsing [], type NULL in /home/httpd/vhosts/ahkorea.de/httpdocs/_share/_shareAjax/class.pAjaxParser.php on line 172 This codes are just for testing, it may contain some typing mistakes. but that's not a problem. everything, that i need for using pAjax is included in _basicSetup.php <? include dirname(__FILE__) . "/_share/_basicSetup.php"; $AJAX = new pAjax; $AJAX->handleRequest("euc-kr"); include $SystemRoot . "_header/_header.php"; ?> <?php pAjax::showJavaScript($WebRoot . "/_share/pAjax"); ?> <SCRIPT type="text/javascript"> function AjaxChat() { pAjax.call(this); pAjax.setDebugMode(false); } var _p = AjaxChat.prototype = new pAjax; </SCRIPT> <input type="hidden" name="chatTextSave" value=""> <form method="post" name="tmpForm" action="<?=$PHP_SELF?>" ENCTYPE="multipart/form-data" onSubmit="return validate(this)"> <input type="hidden" name="mode" value="save"> <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td align="center" colspan="2"> </td> </tr> <tr> <td align="center" width="20%"> </td> <td align="center" width="80%" height="400"><div id="chatWin" style="width: auto; height: 400px; overflow: auto; background-color: #FFFFFF; border: 1px solid #EEEEEE"> </div></td> </tr> <tr> <td align="center" colspan="2"> </td> </tr> <tr> <td align="center" colspan="2"> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td align="center" width="60%"><textarea name="chatText" style="width:210px; height: 60px;"></textarea></td> <td align="center" width="40%"><input type="submit" value="SEND"></td> </tr> </table> </td> </tr> </table> </form> <? include $SystemRoot . "_footer/_footer.php"; ?> Then here i have second problem. as you see in the code, i'm using euc-kr as enconding. but it's not at all working. i tried to solve this already long time. but i'm now kinds of giving up.
![]() Hi!
Thanks for using my class. =) Seems you have a lot of problems with my class, right?! Let's discuss some of them. You used the handleRequest before the end of your PHP code. As written in Basic_Tutorial.txt, "Please notice that handleRequest method should be the last PHP thing in your document, but before any document char be written (because it uses headers)." If you place it as the last PHP command, it'll correct the second warning (Cannot modify Headers). The first and the third messages are strictly connected. Both tells you that you sent a NULL value. Seems my code is wrong, but you need to check something here: <input type="submit" value="SEND"> This does not work in my script. All sent data must be handled via JS and PHP. HTML handling only generate weird errors and you have to prevent it. My suggestions: change the submit to a type="button" and handle the onclick event by adding a JS function related to it. This function should grab the content of the chatTest textarea (also the content of mode) and send it to server. On server, handle it via a method or function, saving it anywhere and returning to you something that your JS will understand. In JS code, grab the recieved data and handle it ie. displaying the recieved info to user and cleaning the chatTest textarea. There's no need of a <form...> HTML tag in my script. I suggest you to take a look at examples available using my script. They can probably help you to understand how my class works. Talking about charset encoding, I tryed in a variety of ways to solve the dependency of MultiByte String extension that commom JSON libs uses. For this, I check which extension I have available and try to use it. The sequence I try is: MultiByte String, IconV and then I simply UTF8_encode. If your charset isn't supported by UTF-8 encoding, you must use then one of the two libraries. I suggest you install MultiByte String. I tested with some charsets in a VPS server with both installed libraries and it works perfectly. If you have any problems regarding this, message me again. I hope this helps you a little bit. Regards,
![]() I've read Basic_Tutorial.txt several times and i can understand what you're saying, but something i don't understand is, that handleRequest() is actually at the end of my document. That's exactly before any char is written and after all other PHP scripts.
As you see in my testing document include $SystemRoot . "_header/_header.php"; _header.php contains every html codes such as <html>. So actually HTML code starts from _header.php. What i mean is, that handleRequest() is called always before any document char. So i wanted to know, if i can submit this form to itself by using action="<?=$PHP_SELF?>". And if submit is not working in your script, hmmm, that's my problem. Because actually i'm using my own validation script classes in my "Project", submit is required by that JS class. so i can't replace submit into button and OnClick(). Encoding is not a big problem as you said. i had a lot of experience of my mother language. so i will fix it anyway. Thanks for your help. bye.
![]() Hi, Guilherme.
I finally found out, that we both misunderstood what each other says. Now i now, what you meant, that submit is not working in your scripts. So, i made a simple example to show, what i really wanted to ask. You will understand that easily. So, here's link you can see. ahkorea.de/btest.php Yes, we'd better speak in PHP. Juhoon Kim p.s. : in case you need full source code check below. ============================================================== ============================================================== ====================FULL SOURCE CODE========================== ============================================================== ============================================================== <? // XMLDomit include_once dirname(__FILE__) . "/_share/_shareXml/xml_domit_include.php"; // pAjax include_once dirname(__FILE__) . "/_share/_shareAjax/class.pAjax.php"; function SetNext($strText) { if ($strText == 1) { $arrReturn[0][value] = 0; $arrReturn[0][text] = "Berlin"; $arrReturn[1][value] = 1; $arrReturn[1][text] = "Bonn"; $arrReturn[2][value] = 2; $arrReturn[2][text] = "Hamburg"; $arrReturn[3][value] = 3; $arrReturn[3][text] = "Dresden"; } else if ($strText == 2) { $arrReturn[0][value] = 0; $arrReturn[0][text] = "Lio de Janeiro"; $arrReturn[1][value] = 1; $arrReturn[1][text] = "Sao Paulo"; $arrReturn[2][value] = 2; $arrReturn[2][text] = "Mato Grosso"; } return $arrReturn; } $AJAX = new pAjax; $AJAX->handleRequest("euc-kr"); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=euc-kr"> <TITLE>Testing pAjax</TITLE> <META NAME="Generator" CONTENT="EditPlus2"> <META NAME="Author" CONTENT="Kimjuhoon"> <META NAME="Keywords" CONTENT="ahkorea"> <META NAME="Description" CONTENT="yellow page"> </HEAD> <BODY bgcolor='#FFFFFF' text='#000000' leftmargin='0' topmargin='0' link='#6699FF' vlink='#FF6600' alink='#CC33FF'> <?php pAjax::showJavaScript("/_share/_shareAjax"); ?> <SCRIPT type="text/javascript"> <!-- function ahjax() { pAjax.call(this); pAjax.setDebugMode(false); } var _p = ahjax.prototype = new pAjax; _p.searchnext = function() { var objRequest = this.prepare("SetNext", pAjaxRequest.POST); objRequest.setParam("value1", document.getElementById("country").value); objRequest.execute(); } _p.onLoad = function() { var data = this.getResponse(); for (var item in data) { newOption = document.createElement('OPTION'); for (var innerItem in data[item]) { newOption.text = data[item][innerItem]; newOption.value = data[item][innerItem]; } document.tmpForm.city.add(newOption); } } var kkk = new ahjax; //--> </SCRIPT> <input type="hidden" name="chatTextSave" value=""> <form method="post" name="tmpForm" action="<?=$PHP_SELF?>" onSubmit="return validate(this)"> <input type="hidden" name="mode" value="save"> <table width="400" border="0" align="center" cellpadding="0" cellspacing="0"> <tr height="50"> <td align="center" width="150">name</td> <td align="center"><input type="text" name="name"></td> </tr> <tr height="50"> <td align="center" width="150">email</td> <td align="center"><input type="text" name="email"></td> </tr> <tr height="50"> <td align="center" width="150">address</td> <td align="center"><input type="text" name="address"></td> </tr> <tr height="50"> <td align="center" colspan="2"> <table width="100%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FF0000"> <tr height="50"> <td align="center" width="150">country</td> <td align="center"> <select name="country" OnChange="kkk.searchnext();"> <option>If you select this</option> <option value="1">Germany</option> <option value="2">Brazil</option> </select> </td> </tr> <tr height="50"> <td align="center">City</td> <td align="center"> <select name="city"> <option>This will be set</option> </select> </td> </tr> </table> </td> </tr> <tr height="50"> <td align="center" width="150">telephone</td> <td align="center"><input type="text" name="telephone"></td> </tr> <tr height="50"> <td colspan="2"> <table width="100%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FF0000"> <tr height="50"> <td align="center"><font color="red">When you press the submit below to save it into database. it will make error.</font></td> </tr> <tr height="50"> <td align="center"><input type="submit"></td> </tr> </table> </td> </tr> </table> </form> </BODY> </HTML>
![]() Try removing the [onsubmit="return validate(this)"]
This is disabling your form to be posted. =) If the example still doesn't work, message here again. Regards,
![]() I removed it. but error is same like before.
if i set "action" to other page like action="other.php". It's working perfectly. only problem is when i set it as "$PHP_SELF". i can't avoid that in my project. Best Regards.
![]() Have you tryed instead of $PHP_SELF this: $_SERVER['PHP_SELF']?
This can be a problem too. =) Regards, |
info at phpclasses dot org
.