Ajax Validation Failing for Chinese Characters

  • Thread starter Thread starter ngkamsengpeter
  • Start date Start date
  • Tags Tags
    Failing
ngkamsengpeter
Messages
193
Reaction score
0
When I using Ajax to validate whether the username is exist my form , I can validate it when the username is in English character but when it is chinese character , it always can't find the username in my database eventhough the username is exist . However , when I submit the form , it can find the username in the database in chinese character . What it the problem ?
 
Technology news on Phys.org
probably response encoding does not match its actual content (chinese characters). I think you will have more luck in fighting it on server side.
 
whatta said:
probably response encoding does not match its actual content (chinese characters). I think you will have more luck in fighting it on server side.
What do you mean , you mean the response from mysql ? I think it is ok because it works when I submit the form but it don't works when using ajax which doesn't submit the form .What is the problem
 
No, I think whatta meant that since AJAX has to construct a request to the server manually, it's not encoding the request correctly. Make sure AJAX is correctly encoding it.

In AJAX, you have to manually encode everything, or use an appropriate encode function. For example, in AJAX you have to call encode to convert & to "&" or else PHP can not read it correctly.
 
Sane, I was under impression he has a problem on client side:
I using Ajax to validate whether the username is exist
But yes, when I think about it now, you could be right. It's hard to guess without any code given.
 
Whatta, what I had just finished describing was client side.

AJAX is client side. A request is client side. The client builds a request, with javascript, and sends this request to a server. That's AJAX.
 
what I had in mind is that it pulls list of names and verifies it in browser. what you seem to suggest is that it sends the username and server does verification.

either way, it seems that encoding is set wrong at some point inbetween.
 
I don't know how to encode it in the serverside .But I don't think is the encoding problem because I have tested it by placing an echo before validating process and it show the correct chinese words to me . Please help
 
How are you sending data to the server, via GET or POST?
 
  • #10
-Job- said:
How are you sending data to the server, via GET or POST?
Using post .
 
  • #11
Someone please help me .
 
  • #12
elaborate.
 
  • #13
whatta said:
elaborate.
what are you mean ?
 
  • #14
First thing you should focus on is ensuring PHP is properly receiving the data from the Ajax POST request. Is it properly formatted? On the javascript side did you escape the values using escape() before sending them to the PHP side via Ajax?
 
  • #15
i mean show us some code
 
  • #16
-Job- said:
First thing you should focus on is ensuring PHP is properly receiving the data from the Ajax POST request. Is it properly formatted? On the javascript side did you escape the values using escape() before sending them to the PHP side via Ajax?
I think it is propely formated because I echo it at the php side after receiving the data and it show correctly .
 

Similar threads

  • · Replies 18 ·
Replies
18
Views
5K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 16 ·
Replies
16
Views
7K
Replies
2
Views
3K
Replies
1
Views
8K