0

我试图找出一种方法,只使用我的内联 HTML 作为 ajax GET 方法的 URL,而不是从单独的网页获取数据。这可能吗?

这是我的ajax代码:

       $.ajax({
          type: "GET",
          url: $(elm).attr("href"),
          success: function(data){
            $("#pageslide-content").html(data)
              .queue(function(){
                $(this).dequeue();

                // restore working order to all anchors
                $("#pageslide-slide-wrap a").unbind('click').click(function(elm){
                  document.location.href = elm.target.href;
                });

                // add hook for a close button
                $(this).find('.pageslide-close').unbind('click').click(function(elm){
                  _closeSlide(elm);
                  $(this).find('pageslide-close').unbind('click');
                });
                settings.complete();
              });
          }
        });
      });

任何帮助都会很棒!

更新

SOLVED:

             $("#pageslide-content").html('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title></title></head?<body><strong style="color:#C63; font-size:28px; font-weight:bold;">TEST</strong></body></html>')
              .queue(function(){
                $(this).dequeue();

                // restore working order to all anchors
                $("#pageslide-slide-wrap a").unbind('click').click(function(elm){
                  document.location.href = elm.target.href;
                });

                // add hook for a close button
                $(this).find('.pageslide-close').unbind('click').click(function(elm){
                  _closeSlide(elm);
                  $(this).find('pageslide-close').unbind('click');
                });
                settings.complete();
              });
4

2 回答 2

1

是的,当然有可能。您可以从任何地方获取字符串,并将其用于您的 URL 属性。

于 2012-08-17T03:03:46.673 回答
0
             $("#pageslide-content").html('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title></title></head?<body><strong style="color:#C63; font-size:28px; font-weight:bold;">TEST</strong></body></html>')
              .queue(function(){
                $(this).dequeue();

                // restore working order to all anchors
                $("#pageslide-slide-wrap a").unbind('click').click(function(elm){
                  document.location.href = elm.target.href;
                });

                // add hook for a close button
                $(this).find('.pageslide-close').unbind('click').click(function(elm){
                  _closeSlide(elm);
                  $(this).find('pageslide-close').unbind('click');
                });
                settings.complete();
              });
于 2012-08-17T03:42:34.880 回答