weixin_33719619 2015-02-02 22:00 采纳率: 0%
浏览 38

Gulp Browsersync路径

I got a problem with requesting a file via ajax post request.

I wonder how do I map my file on an ajax call to match the servers pathing? I don't get why it is not working (was using XAMPP before switching to a gulp webserver). Here is my project structure:

./
|_ site/
|  |_ index.html
|  |_ php/Gallery.php
|  |_ assets/
|     |_ js/
|        |_ Ajax.js
|        |_ test.html
|
|_ dist/
|
|_ gulpfile.js
|_ package.json
|_ ...

The Ajax.js file does an Post request to get php/gallery.php however I get a 404. I tried "php/Gallery.php" and "../../php/Gallery.php" as a path (and lots of others but try and error did not get me any further)

The Ajax call:

$.ajax({
    url: "php/Gallery.php",
    type: 'post',
    data: { width: $(window).width(), galleryWidth: $('.popup-gallery').innerWidth(),},
    cache: false,
    beforeSend: function(){
      $( ".ajax-loading" ).css('display', 'block');
    },
    success: function(json) {
       ... do something
    },
    error: function(err) {
      console.log("Ajax Error: "+ err);
    }
  }); // end ajax call

I tried to access the test.html file inside of my /js folder with the path: "assets/js/test.html" and I get a 404 there too. If I type the URL "http://localhost:3000/assets/js/test.html" the test.html file gets displayed fine with its "Hello world" so I get really confused.

See picture: http://oi59.tinypic.com/n71op0.jpg (external link cause you need 10 reputation to post images, sadly)

If someone could explain what I am doing wrong here or where's my mistake I would be really grateful!

Thank you

  • 写回答

1条回答 默认 最新

  • weixin_33713350 2015-02-08 12:13
    关注

    The problem was, that the gulp webserver can not interpret PHP. Now I use Xampp and let browsersync proxy through it.

    评论

报告相同问题?

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)