English 中文(简体)
参考数字:jQuery.ajax(DOM) 说明
原标题:Reference calling DOM element in jQuery.ajax() with dataType script

我要说的是以下设想:

<form action="/something.php" method="GET">Click me</div>

<script type="text/javascript"><!--
    $( form ).submit(function(e) {
        $.ajax({
            url: this.action,
            method: this.method,
            dataType:  script 
        });
        return false;
    });
//--></script>

我的问题涉及通过<条形码>退回的 Java本。 我想提及形式。 通常,我将通过<代码>ts(如我用<代码>this.action和this.method。 然而,在我回来时,这似乎并没有奏效:

alert(this);  // displays: [object Window]

它像“ j”一样,在窗户的幌子下执行文字,而不是当场活动的内容。 是否有办法可以轻易地提及事件现场的标语,而不必提及返回的贾瓦文中的内容和内容?

最佳回答

我发现,我可以做以下工作,以允许<条码>>这一在提及点击标语时使用,但我感到,这比所要求的要好得多:

<form action="/something.php" method="GET">Click me</div>

<script type="text/javascript"><!--
    $( form ).submit(function(e) {
        $.ajax({
            url: this.action,
            method: this.method,
            dataType:  text ,
            success: function(data) {
                eval( (function() {  + data +  }).call(this); );
            }
        });
        return false;
    });
//--></script>
问题回答

以这种方式努力:

http://www.un.org。

html:

<div>
   <form id="myCorrectForm" action="/something.php" method="GET">
     <input type="submit" value="Click me" />
   </form>
</div>

j)

<script type="text/javascript"><!--

   // in this environment is created for the variable "frmRef" public
   var frmRef = null;
   $( #myCorrectForm ).submit(function(e) {
      frmRef = $(this);
      $.ajax({
        url: frmRef.attr("action"),
        method: frmRef.attr("method"),
        dataType:  script 
      });
      return false;
   });

//--></script> 

js in “/aboutthing.php”:

alert($(window.parent.frmRef).attr( id ));




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签