笑故挽风 2014-08-12 10:37 采纳率: 100%
浏览 32

ajax url不会调用php文件

I am trying to update the user input ratings through ajax call. This one alert(performance_rating) returned the user input ratings properly. But, I have a problem with my url. it won't call user_ratings.php. I don't know why? I have tried alert function in user_ratings.php page. But, it won't alert.

I have the user_ratings.php file in siteurl.com/include/pages/user_ratings.php How do I call my php file properly?

ajax request

$(function () {
    $('#form').on('submit', function (e) {
      performance_rating = $('input:radio[name=rating]:checked').val();
      e.preventDefault();
      $.ajax({
        type: 'POST',
        url: 'user_ratings.php',
        data: {
            rating: performance_rating
        },
        success: function() {
            alert(performance_rating);
        }
      });
    });
});
  • 写回答

3条回答 默认 最新

  • from.. 2014-08-12 10:53
    关注

    first its better you do this

    define("URL", "http://siteurl.com/");
    

    Then in the ajax url section write

    url: '<?php echo URL ;?>includes/pages/user_ratings.php',
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型