空间Ajax响应之前(jQuery的,PHP) [英] Space Before Ajax Response (jQuery, PHP)

查看:132
本文介绍了空间Ajax响应之前(jQuery的,PHP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用jQuery做Ajax请求。数据越来越到PHP很好,但反应不是又回到了JavaScript的正常工作。不知怎的,有响应之前的空间。我知道这是因为萤火虫是这么说的,我的code没有工作,因为空间是存在的。当我想到那里是一个空间,它工作正常。任何想法,以什么可以补充的空间?

下面是我的ajax功能:

 函数my_ajax(aurl,ADATA,aretfunc){
 $阿贾克斯({
  键入:POST,
  网址:aurl,
  数据:ADATA,
  成功:函数(MSG){
    的eval(aretfunc +'(MSG);');
  }
 });
}
 

解决方案

查找&LT之外的虚假空白字符;?PHP> 标签在你的PHP文件。在执行PHP脚本时,任何这样的空白将得到输出。如果你的PHP文件包括其他PHP文件,同样的道理也适用于这些文件也是如此。

I'm using jQuery to make ajax requests. The data is getting to PHP nicely, but the response isn't getting back to javascript properly. Somehow there is a space before the response. I know this because Firebug says so and my code doesn't work because the space is there. When I expect there to be a space it works fine. Any ideas as to what could be adding the space?

Here is my ajax function:

function my_ajax (aurl, adata, aretfunc) {
 $.ajax({
  type: "POST",
  url: aurl,
  data: adata,
  success: function(msg) {
    eval(aretfunc+'(msg);');
  }
 });
}

解决方案

Look for spurious whitespace characters outside of the <?php ?> tags in your PHP file. Any such whitespace will get output when the PHP script is executed. If your PHP file includes other PHP files, the same thing applies to those files as well.

这篇关于空间Ajax响应之前(jQuery的,PHP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆