dongshiqin1352 2019-05-21 22:44
浏览 155

使用PHP读取文本文件并将其返回给JavaScript [重复]

This question already has an answer here:

I want to get the content of a txt file in JavaScript, so I want to call a php file to open and save the content of the text file into a variable and return it to JS is that possible? I've sent variables from js to php with $.post() and I tried to use $.get("php file") but I can't return the file content can anybody help me?

</div>
  • 写回答

1条回答 默认 最新

  • doufutao4428 2019-05-21 22:54
    关注

    To read/get a file from the server and use it contents in javascript/jquery, you can use the shorthand-method $.get. Inside the callback-function, you are able to process the data returned from the server.

    $.get("file.php", function(data) {
      console.log(data);
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作