Undefined index: Error in ajax POST and/or php script?

前端 未结 4 1198
清歌不尽
清歌不尽 2021-01-13 22:12

I\'m trying to send an ajax POST to a php file, however the php file sends a notice of \"undefined index\", and the php file never seems to receive the value i\'m trying to

4条回答
  •  星月不相逢
    2021-01-13 22:50

    The problem can come from the dataType not being specified or that the dataType specified does not match thus returned by the server.

    Explicitely set the dataType, e.g. dataType:'json'

    and make sure that your script returns data that is "encoded" in the data type that you chose, e.g. in PHP:

    echo json_encode($something);

提交回复
热议问题