0

I have a PHP script that returns information - this is working as expected and I'm seeing the TM symbol correctly. This uses the URL www.example.com/search/search_box.php?search_phrase=seattle

However, when I call the page AJAX post, I see black diamonds where the TM should be.

My call is:

$.post("/search/search_box.php", {search_phrase: "seattle"}, function(data) {
    var strResponse = data;
    $("#output_area").html(strResponse);
});

jQuery is linked from the CDN:

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>

Both search_box.php and the calling page are UTF-8 encoded (using Notepad++ as the editor). The calling page is a simple page that doesn't have ANY includes or scripts.

Suggestions would be appreciated please?

JezB
  • 528
  • 1
  • 10
  • 26
  • 1
    If I remember correctly, your site and json response encodings probably do not match or you forgot to encode your response to utf8. Otherwise you can always try the (more ugly) `htmlentities()`... – Raphioly-San Jan 11 '16 at 10:29

2 Answers2

0

If i can see good , and i can, you're using GET to parse search_phrase in php side, and you are posting on jquery , try using $.get https://api.jquery.com/jquery.get/

Marko Mackic
  • 2,293
  • 1
  • 10
  • 19
0

In PHP file set header for encoding

header('Content-Type: text/html; charset=utf-8');

refer: Set HTTP header to UTF-8 using PHP

Also the result you are trying to send from PHP file must be converted to UTF-8

$result= mb_convert_encoding($result, 'HTML-ENTITIES', "UTF-8");

refer: http://php.net/manual/en/function.mb-convert-encoding.php

Community
  • 1
  • 1
Vegeta
  • 1,319
  • 7
  • 17
  • I'm setting the Content-Type in header, but there's no difference. And if I add this to search_box.php, the direct URL output is wrong. – JezB Jan 11 '16 at 14:01