473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Confirm with Ajax

Hello,

I am trying to confirm whether a user wants to perform a desired action using AJAX and am having trouble getting it to work.

I have this function:
Expand|Select|Wrap|Line Numbers
  1. function confirmPost() {
  2.   var agree = confirm("Are you sure you want to remove?");
  3.   if ( agree ) {
  4.     return true;
  5.   } else {
  6.     return false;
  7.   }
  8. }
  9.  
I then use the function in this event:
Expand|Select|Wrap|Line Numbers
  1.         $('#POCs').delegate( "a.remove", "click", function(){
  2.           confirmPost();
  3.           var id = $(this).attr( 'id' ).replace( /remove-/, '' );
  4.           var team_id = $('#auto_cat').val();
  5.           $.ajax({
  6.             type: "POST",
  7.             url: "delete.php",
  8.             data: { id: id, bucket_id: team_id },
  9.             success: function(resp){
  10.               $('#POCs').empty();
  11.               $('#POCs').html( resp );
  12.             }
  13.           });
  14.           return false;
  15.         });
  16.  
The dialog box comes up, but if I click 'OK' or 'Cancel' nothing happens.

Any assistance on this matter would be greatly appreciated!
Jul 19 '11 #1

✓ answered by Dormilich

The dialog box comes up, but if I click 'OK' or 'Cancel' nothing happens.
why should something happen? the code does what it is told to do.

maybe you should add a breaking condition
Expand|Select|Wrap|Line Numbers
  1. if (!confirmPost()) {
  2.     return false;
  3. }

2 3255
Dormilich
8,658 Expert Mod 8TB
The dialog box comes up, but if I click 'OK' or 'Cancel' nothing happens.
why should something happen? the code does what it is told to do.

maybe you should add a breaking condition
Expand|Select|Wrap|Line Numbers
  1. if (!confirmPost()) {
  2.     return false;
  3. }
Jul 19 '11 #2
I just needed to add a little bit of logic to get it going. Thanks for your help!
Jul 19 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: wonderu | last post by:
Hi! I have the AJAX-script. It eats memory about 4Kb per one callback. Script reflects messages from server application in real-time. I form messages, and put them into the iframe. If mesages more...
1
by: danxavier | last post by:
I successfuly installed dd.php and sajax.php files. It runs fine, but I would like to link the $items to an image. I called the field in mysql with the link "pic". Any help would be AWESOME!!! I've...
4
by: mamun | last post by:
Hi All, I have the following situation and am looking for answer in C#. I have a datagrid and putting checkbox next to each record. In the header I have a Delete button. I want users to...
8
by: jd2007 | last post by:
Why the Ajax code below in ajax.js is causing my form not to work ? ajax.js: var a=0; var b=0; var c=0; var d=0; var e=0; var f=0;
0
by: =?Utf-8?B?TGlhbQ==?= | last post by:
Hi, I've implemented AJAX on to one of my pages, I am developing on Windows XP with VS05, I have IIS set up on XP so connect to the dev site using IE and when clicking a control on the...
8
by: gearoid | last post by:
Hey I've designed an intranet site where users can upload documents (called 'resources') as part of a knowledge base. Part of the functionality of said site is that privilaged users can edit the...
5
by: simon | last post by:
hello, I have a server set up on my local (home) network and can not get an ajax application to run on the box. it works fine on our developement server and also works fine locally. I...
0
by: JamesUmokoro | last post by:
Gridview confirm deleting with confirm box in ajax is not working with ImageButton control. Can any one help me in solving this problem? it works fine with the LinkButton control but does'nt work...
4
by: dgourd | last post by:
I have a a PHP script that does all the logging in and creating session. I also have some javascript that uses AJAX to make a request to the PHP script and return the response. The problem I run...
3
by: neovantage | last post by:
Hi Experts, I have create a jQuery ui function which delete product from the shopping list. After receiving a jQuery Ajax response i want to bind the same function which load on page load. How can i...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.