Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 222
  • Last Modified:

Sending Data to a php file with jquery

Hello Experts,

I have this javascript and it works intermittently... can someone help?

<script type="text/javascript">
$(document).ready(function() {
  $('.delete').click(function(event) {
    event.preventDefault()
    var url = $(this).attr('href');
    var confirm_box = confirm('Are you sure you want to click this link?');
    if (confirm_box) {
            $.ajax({
  url: url,
});
location.reload();
 
       //uncomment below and remove above if you want the link to open in a new window
       //window.open(url,'_blank');
    }
  });
});
</script>


<a href="/delete.php?type=news&id=18" class="delete"><img src="/images/delete.png" alt="Delete" border="0"/></a>
 <a href="/delete.php?type=news&id=19" class="delete"><img src="/images/delete.png" alt="Delete" border="0"/></a>
<a href="/delete.php?type=news&id=20" class="delete"><img src="/images/delete.png" alt="Delete" border="0"/></a>


Any IDeas?
0
maccaj51
Asked:
maccaj51
  • 2
1 Solution
 
HainKurtSr. System AnalystCommented:
can you please have a look at your previous question again (27385646)
The answer you accepted is same as the one I posted first...
0
 
leakim971PluritechnicianCommented:
Use : $.ajax({ url:url, async:false });

<script type="text/javascript">
$(document).ready(function() {
  $('.delete').click(function(event) {
    event.preventDefault()
    var url = $(this).attr('href');
    var confirm_box = confirm('Are you sure you want to click this link?');
    if (confirm_box) {
            $.ajax({ url: url, async:false });
            location.reload();
 
       //uncomment below and remove above if you want the link to open in a new window
       //window.open(url,'_blank');
    }
  });
});
</script>

Open in new window


http://www.allinterview.com/showanswers/88917.html
http://www.phpmind.com/blog/2010/07/what-is-ajax-synchronous-and-asynchronous/
http://newtechies.blogspot.com/2007/12/synchronous-requests-versus.html
http://arshadinfo.wordpress.com/2008/05/25/what-is-the-difference-between-asynchronous-ajax-and-synchronous-request/
0
 
maccaj51Author Commented:
Im Sorry HainKurt... I am so new to this that I didnt (and still dont) realise...

Id be more than happy to give you the points here if you can have a quick look
0
 
maccaj51Author Commented:
Many Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now