10.24 2011-05-30 11:13 采纳率: 0%
浏览 102

为什么第一次 ajax 调用不起作用?

我第一次尝试使用Ajax,但是它不起作用。这是处理ajax调用的“ some.php”:

<?php
    echo "success";
?>

这是调用它的javascript:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.min.js"></script>
<script type="text/javascript">

var msg;

$.ajax({
   type: "POST",
   url: "some.php",
   data: ({ })
   success: function(msg){
     alert( msg );
   }
 });
</script>

你能看到问题出在哪里吗?

我正在wordpress下工作,并且两个文件都位于\wp-content\themes\twentyten中(也许ajax调用中的网址是错误的?)

  • 写回答

3条回答 默认 最新

  • weixin_33720452 2011-05-30 11:19
    关注

    First of all remove the data:({}) which is pointless. you are also missing a , behind your data statement. this is most likely the issue.

    if both the files is in the same directory, then the url should be correct.

    However, i urge you to use a tool like FireBug in order to debug your problem further

    评论

报告相同问题?

悬赏问题

  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了