Python论坛  - 讨论区

标题:[python-chinese] 关于JQuery ajax的两点疑问.

2007年05月15日 星期二 17:17

flyaflya flyaflya在gmail.com
星期二 五月 15 17:17:16 HKT 2007

²âÊÔ´úÂëÈëÏ£º
htmlÎļþÖеÄajax´úÂ룺
    $("#testAj").click(
        function(){
        $.get("testaj.html", {data: "mmmm"},
            function(msg){
                alert(msg);
            }
        )
        }
   £©

djangoµÄviewÖеĴúÂ룺
def testaj(request):
    return HttpResponse(simplejson.dumps({"text": "mmmm", "mm": "dddd"}),
mimetype='application/javascript')

ÓÐÁ½¸öÎÊÌ⣺
1.ÈçºÎ°Ñ$.getÌæ»»³É$.post¾Í²»Äܵ¯³ö¶Ô»°¿òÁË£¬¿´jqueryµÄÎĵµÀgetºÍpost¶¼¿ÉÒÔajaxµÄ¡£
2.alert(msg)  ¿ÉÒÔÏÔʾ×Ö·û´®"{"text": "mmmm", "mm": "dddd"}"£¬µ«ÊÇÈç¹û¸Ä³Éalert(msg.mm
)»òalert(msg[0])ÏÔʾΪ¿Õ£¬ÎÒ¿´ÍøÉϵÄһЩ½Ì³Ì°üÀ¨limodouµÄ¡¶step¡·½Ì³Ì¶¼ÊÇÕâÑùдµÄ£¬ÎªÊ²Ã´ÕâÀï²»ÐУ¿Èç¹ûд³Éalert(eval(
msg.mm)[0])¾Í²»Äܵ¯³ö¶Ô»°¿ò£¬ÎªÊ²Ã´ÄØ£¿

-- 
http://www.flyaflya.com
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070515/77077754/attachment.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年05月15日 星期二 17:22

头太晕 torrycn在gmail.com
星期二 五月 15 17:22:56 HKT 2007

ÄãÍøÕ¾ÉϵÄÓÎÏ·Ôõô²»ÌṩԴÂë°¡£¿

ÔÚ07-5-15£¬flyaflya <flyaflya在gmail.com> дµÀ£º
>
> ²âÊÔ´úÂëÈëÏ£º
> htmlÎļþÖеÄajax´úÂ룺
>     $("#testAj").click(
>         function(){
>         $.get("testaj.html", {data: "mmmm"},
>             function(msg){
>                 alert(msg);
>             }
>         )
>         }
>    £©
>
> djangoµÄviewÖеĴúÂ룺
> def testaj(request):
>     return HttpResponse(simplejson.dumps({"text": "mmmm", "mm": "dddd"}),
> mimetype='application/javascript')
>
> ÓÐÁ½¸öÎÊÌ⣺
> 1.ÈçºÎ°Ñ$.getÌæ»»³É$.post¾Í²»Äܵ¯³ö¶Ô»°¿òÁË£¬¿´jqueryµÄÎĵµÀgetºÍpost¶¼¿ÉÒÔajaxµÄ¡£
> 2.alert(msg)  ¿ÉÒÔÏÔʾ×Ö·û´®"{"text": "mmmm", "mm": "dddd"}"£¬µ«ÊÇÈç¹û¸Ä³Éalert(msg.mm)»òalert(msg[0])ÏÔʾΪ¿Õ£¬ÎÒ¿´ÍøÉϵÄһЩ½Ì³Ì°üÀ¨limodouµÄ¡¶step¡·½Ì³Ì¶¼ÊÇÕâÑùдµÄ£¬ÎªÊ²Ã´ÕâÀï²»ÐУ¿Èç¹ûд³Éalert(eval(
> msg.mm)[0])¾Í²»Äܵ¯³ö¶Ô»°¿ò£¬ÎªÊ²Ã´ÄØ£¿
>
> --
> http://www.flyaflya.com
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070515/db097ea8/attachment.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年05月15日 星期二 17:28

flyaflya flyaflya在gmail.com
星期二 五月 15 17:28:16 HKT 2007

»¹²»ÄÜÌṩԴÂ룬Ҫ¿¿Ëü׬ЩÁãÓÃÇ®¡£

On 5/15/07, Í·Ì«ÔÎ <torrycn在gmail.com> wrote:
>
> ÄãÍøÕ¾ÉϵÄÓÎÏ·Ôõô²»ÌṩԴÂë°¡£¿
>
> ÔÚ07-5-15£¬flyaflya <flyaflya在gmail.com> дµÀ£º
> >
> >  ²âÊÔ´úÂëÈëÏ£º
> > htmlÎļþÖеÄajax´úÂ룺
> >     $("#testAj").click(
> >         function(){
> >         $.get("testaj.html", {data: "mmmm"},
> >             function(msg){
> >                 alert(msg);
> >             }
> >         )
> >         }
> >    £©
> >
> > djangoµÄviewÖеĴúÂ룺
> > def testaj(request):
> >     return HttpResponse(simplejson.dumps({"text": "mmmm", "mm":
> > "dddd"}), mimetype='application/javascript')
> >
> > ÓÐÁ½¸öÎÊÌ⣺
> > 1.ÈçºÎ°Ñ$.getÌæ»»³É$.post¾Í²»Äܵ¯³ö¶Ô»°¿òÁË£¬¿´jqueryµÄÎĵµÀgetºÍpost¶¼¿ÉÒÔajaxµÄ¡£
> > 2.alert(msg)  ¿ÉÒÔÏÔʾ×Ö·û´®"{"text": "mmmm", "mm": "dddd"}"£¬µ«ÊÇÈç¹û¸Ä³Éalert(msg.mm
> > )»òalert(msg[0])ÏÔʾΪ¿Õ£¬ÎÒ¿´ÍøÉϵÄһЩ½Ì³Ì°üÀ¨limodouµÄ¡¶step¡·½Ì³Ì¶¼ÊÇÕâÑùдµÄ£¬ÎªÊ²Ã´ÕâÀï²»ÐУ¿Èç¹ûд³Éalert(eval(
> > msg.mm)[0])¾Í²»Äܵ¯³ö¶Ô»°¿ò£¬ÎªÊ²Ã´ÄØ£¿
> >
> > --
> > http://www.flyaflya.com
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>



-- 
http://www.flyaflya.com
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070515/51d43fce/attachment.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年05月15日 星期二 17:55

李阳 linuxbbs在163.com
星期二 五月 15 17:55:45 HKT 2007

不至于吧。。。找些项目做做不是更好?
  ----- Original Message ----- 
  From: flyaflya 
  To: python-chinese at lists.python.cn 
  Sent: Tuesday, May 15, 2007 5:28 PM
  Subject: Re: [python-chinese]关于JQuery ajax的两点疑问.


  还不能提供源码,要靠它赚些零用钱。


  On 5/15/07, 头太晕 <torrycn at gmail.com> wrote: 
    你网站上的游戏怎么不提供源码啊? 


    在07-5-15,flyaflya <flyaflya at gmail.com> 写道: 
      测试代码入下:
      html文件中的ajax代码:
          $("#testAj").click(
              function(){
              $.get("testaj.html", {data: "mmmm"},
                  function(msg){
                      alert(msg);
                  }
              ) 
              }
         )  

      django的view中的代码:
      def testaj(request):   
          return HttpResponse(simplejson.dumps({"text": "mmmm", "mm": "dddd"}), mimetype='application/javascript')

      有两个问题:
      1.如何把$.get替换成$.post就不能弹出对话框了,看jquery的文档里,get和post都可以ajax的。
      2.alert(msg)  可以显示字符串"{"text": "mmmm", "mm": "dddd"}",但是如果改成alert(msg.mm )或alert(msg[0])显示为空,我看网上的一些教程包括limodou的《step》教程都是这样写的,为什么这里不行?如果写成alert(eval( msg.mm)[0])就不能弹出对话框,为什么呢?

      -- 
      http://www.flyaflya.com 

      _______________________________________________
      python-chinese 
      Post: send python-chinese at lists.python.cn 
      Subscribe: send subscribe to python-chinese-request at lists.python.cn
      Unsubscribe: send unsubscribe to   python-chinese-request at lists.python.cn 
      Detail Info: http://python.cn/mailman/listinfo/python-chinese



    _______________________________________________
    python-chinese
    Post: send python-chinese at lists.python.cn 
    Subscribe: send subscribe to python-chinese-request at lists.python.cn
    Unsubscribe: send unsubscribe to   python-chinese-request at lists.python.cn
    Detail Info: http://python.cn/mailman/listinfo/python-chinese




  -- 
  http://www.flyaflya.com 


------------------------------------------------------------------------------


  _______________________________________________
  python-chinese
  Post: send python-chinese at lists.python.cn
  Subscribe: send subscribe to python-chinese-request at lists.python.cn
  Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
  Detail Info: http://python.cn/mailman/listinfo/python-chinese
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://python.cn/pipermail/python-chinese/attachments/20070515/fc6a5a51/attachment-0001.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年05月15日 星期二 18:12

Tian askfor在gmail.com
星期二 五月 15 18:12:07 HKT 2007

ÓÃpythonдµÄ£¿

On 5/15/07, flyaflya <flyaflya在gmail.com> wrote:
>
> »¹²»ÄÜÌṩԴÂ룬Ҫ¿¿Ëü׬ЩÁãÓÃÇ®¡£
>
> On 5/15/07, Í·Ì«ÔÎ <torrycn在gmail.com> wrote:
> >
> > ÄãÍøÕ¾ÉϵÄÓÎÏ·Ôõô²»ÌṩԴÂë°¡£¿
> >
> > ÔÚ07-5-15£¬flyaflya <flyaflya在gmail.com> дµÀ£º
> > >
> > >  ²âÊÔ´úÂëÈëÏ£º
> > > htmlÎļþÖеÄajax´úÂ룺
> > >     $("#testAj").click(
> > >         function(){
> > >         $.get("testaj.html", {data: "mmmm"},
> > >             function(msg){
> > >                 alert(msg);
> > >             }
> > >         )
> > >         }
> > >    £©
> > >
> > > djangoµÄviewÖеĴúÂ룺
> > > def testaj(request):
> > >     return HttpResponse(simplejson.dumps({"text": "mmmm", "mm":
> > > "dddd"}), mimetype='application/javascript')
> > >
> > > ÓÐÁ½¸öÎÊÌ⣺
> > > 1.ÈçºÎ°Ñ$.getÌæ»»³É$.post¾Í²»Äܵ¯³ö¶Ô»°¿òÁË£¬¿´jqueryµÄÎĵµÀgetºÍpost¶¼¿ÉÒÔajaxµÄ¡£
> > > 2.alert(msg)  ¿ÉÒÔÏÔʾ×Ö·û´®"{"text": "mmmm", "mm": "dddd"}"£¬µ«ÊÇÈç¹û¸Ä³Éalert(msg.mm
> > > )»òalert(msg[0])ÏÔʾΪ¿Õ£¬ÎÒ¿´ÍøÉϵÄһЩ½Ì³Ì°üÀ¨limodouµÄ¡¶step¡·½Ì³Ì¶¼ÊÇÕâÑùдµÄ£¬ÎªÊ²Ã´ÕâÀï²»ÐУ¿Èç¹ûд³Éalert(eval(
> > > msg.mm)[0])¾Í²»Äܵ¯³ö¶Ô»°¿ò£¬ÎªÊ²Ã´ÄØ£¿
> > >
> > > --
> > > http://www.flyaflya.com
> > >
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese在lists.python.cn
> > > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > > Unsubscribe: send unsubscribe to   python-chinese-request在lists.python.cn
> > >
> > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > >
> >
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
>
>
>
> --
> http://www.flyaflya.com
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070515/d3fb0dfc/attachment.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年05月16日 星期三 12:42

追风逐月 chinesexu在gmail.com
星期三 五月 16 12:42:04 HKT 2007

Ó¦¸ÃÊÇalert(eval( msg <http://msg.mm/>).mm)°É,
ÄãÍøÕ¾ÉϵÄÓÎÏ·²»´íŶ,ÓÃʲô¶«Î÷¿ª·¢µÄ°¡?

On 5/15/07, Tian <askfor在gmail.com> wrote:
>
> ÓÃpythonдµÄ£¿
>
> On 5/15/07, flyaflya <flyaflya在gmail.com> wrote:
> >
> > »¹²»ÄÜÌṩԴÂ룬Ҫ¿¿Ëü׬ЩÁãÓÃÇ®¡£
> >
> > On 5/15/07, Í·Ì«ÔÎ <torrycn在gmail.com> wrote:
> > >
> > > ÄãÍøÕ¾ÉϵÄÓÎÏ·Ôõô²»ÌṩԴÂë°¡£¿
> > >
> > > ÔÚ07-5-15£¬flyaflya <flyaflya在gmail.com> дµÀ£º
> > > >
> > > >  ²âÊÔ´úÂëÈëÏ£º
> > > > htmlÎļþÖеÄajax´úÂ룺
> > > >     $("#testAj").click(
> > > >         function(){
> > > >         $.get("testaj.html", {data: "mmmm"},
> > > >             function(msg){
> > > >                 alert(msg);
> > > >             }
> > > >         )
> > > >         }
> > > >    £©
> > > >
> > > > djangoµÄviewÖеĴúÂ룺
> > > > def testaj(request):
> > > >     return HttpResponse(simplejson.dumps({"text": "mmmm", "mm":
> > > > "dddd"}), mimetype='application/javascript')
> > > >
> > > > ÓÐÁ½¸öÎÊÌ⣺
> > > > 1.ÈçºÎ°Ñ$.getÌæ»»³É$.post¾Í²»Äܵ¯³ö¶Ô»°¿òÁË£¬¿´jqueryµÄÎĵµÀgetºÍpost¶¼¿ÉÒÔajaxµÄ¡£
> > > > 2.alert(msg)  ¿ÉÒÔÏÔʾ×Ö·û´®"{"text": "mmmm", "mm": "dddd"}"£¬µ«ÊÇÈç¹û¸Ä³Éalert(msg.mm
> > > > )»òalert(msg[0])ÏÔʾΪ¿Õ£¬ÎÒ¿´ÍøÉϵÄһЩ½Ì³Ì°üÀ¨limodouµÄ¡¶step¡·½Ì³Ì¶¼ÊÇÕâÑùдµÄ£¬ÎªÊ²Ã´ÕâÀï²»ÐУ¿Èç¹ûд³Éalert(eval(
> > > > msg.mm)[0])¾Í²»Äܵ¯³ö¶Ô»°¿ò£¬ÎªÊ²Ã´ÄØ£¿
> > > >
> > > > --
> > > > http://www.flyaflya.com
> > > >
> > > > _______________________________________________
> > > > python-chinese
> > > > Post: send python-chinese在lists.python.cn
> > > > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > > > Unsubscribe: send unsubscribe to   python-chinese-request在lists.python.cn
> > > >
> > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > >
> > >
> > >
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese在lists.python.cn
> > > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > > Unsubscribe: send unsubscribe to
> > > python-chinese-request在lists.python.cn
> > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > >
> >
> >
> >
> > --
> > http://www.flyaflya.com
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>



-- 
python c# and opensource
blog:http://www.chyni.cn
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070516/530ab6ff/attachment-0001.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年05月16日 星期三 12:45

limodou limodou在gmail.com
星期三 五月 16 12:45:21 HKT 2007

On 5/16/07, 追风逐月 <chinesexu在gmail.com> wrote:
> 应该是alert(eval( msg).mm)吧,
> 你网站上的游戏不错哦,用什么东西开发的啊?
>
只eval可能是不行的,要前后加'(',')'

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年05月17日 星期四 08:36

Kasicass kasicass在gmail.com
星期四 五月 17 08:36:48 HKT 2007

追风逐月 写道:
> 应该是alert(eval( msg <http://msg.mm/>).mm)吧,
> 你网站上的游戏不错哦,用什么东西开发的啊?

PyGame 做的吧。。。美术很赞啊。。还听到了轩辕剑配乐 :-)

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年05月17日 星期四 17:24

flyaflya flyaflya在gmail.com
星期四 五月 17 17:24:23 HKT 2007

·¢ÏÖÁËÎÊÌâµÄËùÔÚ£¬Ö»Òª¼ÓÉϵÚËĸö²ÎÊý"json"Ò»ÇÐÎÊÌâ¾Í½â¾öÁË£¬ÎĵµÀïÕâÁ½¸öº¯ÊýÖ»ÓÐÈý¸ö²ÎÊý£¬¿´Ô´ÂëʵÊÂÉÏÓеÚËĸö²ÎÊý¡£

On 5/17/07, Kasicass <kasicass在gmail.com> wrote:
>
> ×··çÖðÔ дµÀ:
> > Ó¦¸ÃÊÇalert(eval( msg <http://msg.mm/>).mm)°É,
> > ÄãÍøÕ¾ÉϵÄÓÎÏ·²»´íŶ,ÓÃʲô¶«Î÷¿ª·¢µÄ°¡?
>
> PyGame ×öµÄ°É¡£¡£¡£ÃÀÊõºÜÔÞ°¡¡£¡£»¹Ìýµ½ÁËÐùÔ¯½£ÅäÀÖ :-)
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese




-- 
http://www.flyaflya.com
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070517/b262726c/attachment.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年05月17日 星期四 17:26

flyaflya flyaflya在gmail.com
星期四 五月 17 17:26:08 HKT 2007

ÊÇpygame×÷µÄ£¬»¹ÓÐÒ»µãÒÉÎÊÊÇevalÒ»¸ödictʱΪʲôҪ¼Ó"()"

On 5/17/07, flyaflya <flyaflya在gmail.com> wrote:
>
> ·¢ÏÖÁËÎÊÌâµÄËùÔÚ£¬Ö»Òª¼ÓÉϵÚËĸö²ÎÊý"json"Ò»ÇÐÎÊÌâ¾Í½â¾öÁË£¬ÎĵµÀïÕâÁ½¸öº¯ÊýÖ»ÓÐÈý¸ö²ÎÊý£¬¿´Ô´ÂëʵÊÂÉÏÓеÚËĸö²ÎÊý¡£
>
> On 5/17/07, Kasicass <kasicass在gmail.com > wrote:
> >
> > ×··çÖðÔ дµÀ:
> > > Ó¦¸ÃÊÇalert(eval( msg <http://msg.mm/ >).mm)°É,
> > > ÄãÍøÕ¾ÉϵÄÓÎÏ·²»´íŶ,ÓÃʲô¶«Î÷¿ª·¢µÄ°¡?
> >
> > PyGame ×öµÄ°É¡£¡£¡£ÃÀÊõºÜÔÞ°¡¡£¡£»¹Ìýµ½ÁËÐùÔ¯½£ÅäÀÖ :-)
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
>
>
> --
> http://www.flyaflya.com




-- 
http://www.flyaflya.com
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070517/ede022c5/attachment.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号