Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional Ajax ISBN: 978-0-471-77778-6
This is the forum to discuss the Wrox book Professional Ajax by Nicholas C. Zakas, Jeremy McPeak, Joe Fawcett; ISBN: 9780471777786
Important: For the new 2nd edition of this book, please post here instead: [url="http://p2p.wrox.com/forum.asp?FORUM_ID=307"]http://p2p.wrox.com/forum.asp?FORUM_ID=307[/url]
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Ajax ISBN: 978-0-471-77778-6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 5th, 2006, 02:18 AM
Registered User
 
Join Date: May 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Really Strange...

hi guys..

im trying to do some ajax work here..

search.html
=================
html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256">
    <title>äÙÇã ÈÍË ÇáÅÓÊÈíÇäÇÊ</title>
    <script type="text/javascript"src="zxml.js"></script>

    <script type="text/javascript">
        function requestCustomerInfo() {
        displayCustomerInfo("Searching Stored Surveys....");
            var sId = document.getElementById("txtCustomerId").value;
            var oXmlHttp = zXmlHttp.createRequest();
            oXmlHttp.open("get", "get_search_results.php?id=" + sId, true);
            oXmlHttp.onreadystatechange = function () {
                if (oXmlHttp.readyState == 4) {
                    if (oXmlHttp.status == 200) {
                        displayCustomerInfo(oXmlHttp.responseText);
                    } else {
                        displayCustomerInfo("An error occurred: " + oXmlHttp.statusText); //statusText is not always accurate
                    }
                }
            };
            oXmlHttp.send(null);
        }

        function displayCustomerInfo(sText) {
            var divCustomerInfo = document.getElementById("divCustomerInfo");
            divCustomerInfo.innerHTML = sText;
        }
    </script>
</head>
<body dir="rtl">
    <p>ÃÏÎá ãÇ ÊÑíÏ ÇáÈÍË Úäå:</p>
    <p>ßáãÉ ÇáÈÍË: <input type="text" id="txtCustomerId" value="" dir="rtl" /></p>
    <p><input type="button" value=" ÅÈÏà ÇáÈÍË " onclick="requestCustomerInfo()" /></p>
    <div id="divCustomerInfo"></div>
</body>
</html>

get_search_results.php
===================

<?php
    require_once("./include/db_fns.php");
    header("Content-Type:text/plain ; charset=windows-1256");

    $sID = $_GET["id"];

    $sInfo = "";

    $conn = db_connect();

    //create the SQL query string
    $sql = "Select survey_id,survey_topic from survey_topic where survey_topic like '%$sID%'";
    $result = mysql_query($sql) or die(mysql_error());

    if(mysql_num_rows($result) > 0)
    {
        while($row = mysql_fetch_array($result))
        {
            $survey_id=$row['survey_id'];
            $survey_topic = $row['survey_topic'];

            $sInfo = $sInfo . "<a href=\"preview_results.php?sid=$survey_id\">$surve y_topic</a><br>";
        }
    }
       else
       {
            $sInfo = $sID;#$sql;#"áã äÌÏ ÃíÉ äÊÇÆÌ áÈÍËß...íÑÌì ÇáãÍÇæÇÉ ãÑÉ ÃÎÑì..";
    }



   echo $sInfo;

?>

the problem im facing is...

when im searching for some ARABIC text..the sId (java script variable) has the value of the textbox and when i alert it is shows arabic perfect...but when its sent through the XMLhttp to the php page, the ARABIC text becomes ????? all question marks....i really dunno what's happening...the encoding of the two page is set to the arabic encoding ...

previously i have faced the same issue but it was with MYSQL and i solved it..this time there is no database....

what can be done to solve this problem ??

Regards,

Noor


Reply With Quote
  #2 (permalink)  
Old May 5th, 2006, 11:27 AM
nzakas's Avatar
Wrox Author
 
Join Date: Dec 2004
Location: Peabody, MA, USA.
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Noor,

JavaScript is Unicode compliant, so your Arabic text will always work fine with it. When sending it in text format over HTTP, you need to specify an appropriate encoding. You can try setting this on the XMLHttp object:

Code:
oXmlHttp.setRequestHeader("Content-type", "text/html; charset=UTF-8");
I will admit that encodings are not my strong suit, but this should get you going in the right direction.

Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
http://www.nczonline.net/
Reply With Quote
  #3 (permalink)  
Old May 6th, 2006, 01:53 PM
Registered User
 
Join Date: May 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Mr. Nicholas,

than you for the reply..but the code you passed by made no difference...i think it's something to do with my apache server...i think that i have to add the arabic language to it...

if you have some more ideas or suggestion i'll be very happy to hear from you...

Regards,

Noor

Reply With Quote
  #4 (permalink)  
Old May 6th, 2006, 07:21 PM
nzakas's Avatar
Wrox Author
 
Join Date: Dec 2004
Location: Peabody, MA, USA.
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Noor,

I'm sorry, I don't know enough about setting up Apache to be able to help you with that. Please let me know if you do get it working.

Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
http://www.nczonline.net/
Reply With Quote
  #5 (permalink)  
Old May 7th, 2006, 02:47 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

I'm no PHP expert but this looks wrong:
header("Content-Type:text/plain ; charset=windows-1256");
try
header("Content-Type:text/plain ; charset=charset=UTF-8");



--

Joe (Microsoft MVP - XML)
Reply With Quote
  #6 (permalink)  
Old May 7th, 2006, 08:40 AM
Registered User
 
Join Date: May 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

header("Content-Type:text/plain ; charset=UTF-8");

i tried this one also....there is something really strange....i have the file uploaded alreadyt on the server..when i try to acess the search page from home..i get the encoding problem...but when i check from office,,,i get no encoding problem....what is the reason for that ??

do u think that it's a browser issue or what..

Thanx for the help guys..

Regards,

Noor


Reply With Quote
  #7 (permalink)  
Old May 7th, 2006, 08:59 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

If you're using IE check the setting under view | encoding. I've often found that it's set not to auto select or set on the wrong character set.

--

Joe (Microsoft MVP - XML)
Reply With Quote
  #8 (permalink)  
Old May 7th, 2006, 12:51 PM
Registered User
 
Join Date: May 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi joefawcett,

thanx for the reply,,

but the encoding is correct..i dunno what's the reason..ARABIC text was always a problem..lol

but why on two different systems the page function in different ways ??

thanx for any suggestion..

Noor

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Strange VB Apocolypse2005 Beginning VB 6 3 December 4th, 2006 02:48 PM
strange error dynamic_iiita Beginning PHP 0 May 22nd, 2005 06:14 AM
strange characters Kabe XML 3 March 10th, 2005 08:24 PM
strange situation Vishal_7 ASP.NET 1.0 and 1.1 Basics 0 December 16th, 2004 07:18 PM
Why do my posts look strange? joefawcett Forum and Wrox.com Feedback 2 December 16th, 2004 12:04 PM



All times are GMT -4. The time now is 01:53 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.