无法通过ajax与MAMP加载json

时间:2014-04-14 00:32:16

标签: jquery ajax json mamp

我正在尝试建立一个转型为la Medium

的投资组合

到目前为止,我能够测试它online,但是当我在本地使用MAMP启动它时,它将不会加载内容。相反,我得到了这个错误:

  

无法加载资源:服务器响应状态为404(未找到)jolinmasson.local:8888 / ajax / page:6?_ = 1397435305669

为什么要求输入错误的网址?

这是代码的php / Kirby CMS部分:

<?php

$current = $pages->findByUID('home')->children()->visible()->paginate(1);

foreach($current as $p){
  $data['title'] = ((string)$p->title);
  $data['client'] = ((string)$p->client);
  $data['content'] = ((string)kirbytext($p->text));
    if($p->hasImages()){
      $data['image'] = ((string)$p->images()->first()->url());
  };
  $data['projet'] = ((string)kirbytext($p->imagesprojet));
}

echo json_encode($data);

?>

这是JavaScript的一部分:

ArticleAnimator.contentizeElement = function($el, d){
  $el.find('.big-image').css({ backgroundImage: "url(" + d.image + ")" });
  $el.find('h1.title').html(d.title);
  $el.find('.client').html(d.client);
  $el.find('.content .text').html(d.content);
  $el.find('.projet').html(d.projet);
}

1 个答案:

答案 0 :(得分:0)

最后设法让它使用默认的kirby .htaccess

<IfModule mod_rewrite.c>

RewriteEngine on
RewriteBase /

RewriteRule ^content/(.*)\.(txt|md|mdown)$ error [R=301,L]
RewriteRule ^site/(.*) error [R=301,L]
RewriteRule ^kirby/(.*) error [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php [L]

</IfModule>