簡體   English   中英

使用javascript / ajax通過錨點運行php文件?

[英]run php file through an anchor with javascript/ajax?

我需要所有這些以相同的方式運行,但我需要它加載,以便頁面保持在index.php而up.php運行...任何人有任何想法? 預先感謝您的任何幫助!

<div id="left">
<span class='up'><a href="up.php?key1=<?php echo $mes_id1; ?>&key2=<?php echo $mes_id2 ;?>" class="" id="<?php echo $mes_id1; ?>" name="up"><img src="up.png" alt="Down" /></a></span><br />
<?php echo $totalvotes1; ?><br />
</div>

使用jquery嘗試這樣

$('.up a').bind('click', function(e) {           
  var url = $(this).attr('href');

  e.preventDefault(); // stop the browser from following the link

  //make ajax call
  $.ajax({
   'url' : url ,
   'type' : 'GET',
   'success' : function(data) {
   }
   });
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM