Can't get json data from jQuery ajax call

后端 未结 5 1131
深忆病人
深忆病人 2021-01-05 09:35

I\'m trying to get data from data.php via jQuery ajax call.

My code looks like this:

var jsonData;

$.ajax({
        url: \'data.php\',
         


        
5条回答
  •  青春惊慌失措
    2021-01-05 09:53

    You should be using header() function in your PHP to set the proper response header (content type and charset):

    header('Content-type: application/json; charset=UTF-8');
    

    You should also repeat this at the top of HTML pages:

    
    

    See also:

    PHP UTF-8 cheatsheet

提交回复
热议问题