2013-08-12 52 views
1
$(document).ready(function(){ 
    $("#S1").change(function() 
    { 
     var IDCat=this.value; 
     $.ajax({ 
      type: "GET", 
      url: 'product_modify.php', 
      data: {IDCat:IDCat}, 
      success: function(data) 
      { 
       $("#p1").text(data); 
       $("#tempForm").load('tv_form.php'); 
      }      
     }); 
    }); 
}); 

这是我的代码,在load()功能时,我称之为“tv_form.html”文件,它的工作原理,但是当我称之为“tv_form.php”这是行不通的,错误403禁止 问题出在哪里? .html的作品,但.php不起作用。如何使用jquery ajax将php脚本加载到div中?

+1

确保你的文件名,你应该从服务器运行你的PHP文件。 – sudhakar

+0

PHP文件不打算从客户端运行。这就是它被称为服务器脚本的原因。您可以让PHP文件为您提供一组要插入的HTML元素。 – Angela

+0

谢谢,问题解决了.htaccess。 –

回答

0

添加URL而不是文件名。

$(document).ready(function(){ 
    $("#S1").change(function() 
    { 
    var IDCat=this.value; 
    $.ajax({ 
      type: "GET", 
      url: 'product_modify.php', 
      data: {IDCat:IDCat}, 
      success: function(data) 
      { 
       $("#p1").text(data); 
       $("#tempForm").load('URL to tv_form.php'); // www.example.com/file.php 
      } 
     }); 
     }); 
}); 
相关问题