为什么我的 javascript 在调用 ajax 时不起作用?用jquery

发布于 2024-11-15 21:49:56 字数 1501 浏览 0 评论 0原文

好吧,假设我正在做类似

http://localhost/ajax/social/pull/facebookstatus

的 事情我的 /ajax/social/pull/facebookstatus 有一个脚本,类似于

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
      // Load the Visualization API and the piechart package.
      google.load('visualization', '1', {'packages':['corechart']});

      // Set a callback to run when the Google Visualization API is loaded.
      google.setOnLoadCallback(drawChart);

      // Callback that creates and populates a data table, 
      // instantiates the pie chart, passes in the data and
      // draws it.
      function drawChart() {

      // Create our data table.
      var data = new google.visualization.DataTable();

我试图调用的问题(让我们说在 http://localhost/myprofile

    $.ajax({  
        type: "POST",                    // Using the POST method  
        url: "/ajax/social/pull/facebookstatus",      // The file to call  
        data: myfbdata, 
        dataType: 'html',
        success: function(data) {
        $('#ajax-placeputfb').hide().fadeIn(3000).html(data);
        }  
    });

/ajax/social/pull/facebookstatus 上加载的脚本在 http://localhost 上加载时不起作用/myprofile

有问题吗?

谢谢

亚当·拉马丹

ok lets say im doing something like

http://localhost/ajax/social/pull/facebookstatus

on my /ajax/social/pull/facebookstatus there is a script something like

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
      // Load the Visualization API and the piechart package.
      google.load('visualization', '1', {'packages':['corechart']});

      // Set a callback to run when the Google Visualization API is loaded.
      google.setOnLoadCallback(drawChart);

      // Callback that creates and populates a data table, 
      // instantiates the pie chart, passes in the data and
      // draws it.
      function drawChart() {

      // Create our data table.
      var data = new google.visualization.DataTable();

back to the problem im trying to call ( lets say at http://localhost/myprofile )

    $.ajax({  
        type: "POST",                    // Using the POST method  
        url: "/ajax/social/pull/facebookstatus",      // The file to call  
        data: myfbdata, 
        dataType: 'html',
        success: function(data) {
        $('#ajax-placeputfb').hide().fadeIn(3000).html(data);
        }  
    });

the script on /ajax/social/pull/facebookstatus doesnt work when its loaded on http://localhost/myprofile

is there a problem?

Thanks

Adam Ramadhan

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

做个ˇ局外人 2024-11-22 21:49:56

这是一个相关的问题吗? 通过ajax加载html页面时,会加载脚本标签吗?

当lib未包含在中时,我遇到了类似的问题

也许你可以尝试将其包含在主文档的 标记

;

is this a related question? When loading an html page via ajax, will script tags be loaded?

A similar issue I had when the lib was not included in the <head>

Maybe you can try including this in the <head> tag of your main document

<script type="text/javascript" src="https://www.google.com/jsapi"></script>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文