Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 323241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:00:46+00:00 2026-05-12T09:00:46+00:00

A couple of questions, first with this var string below, the 1 one works

  • 0

A couple of questions, first with this var string below, the 1 one works but I need to get the second one working, there is a snytax error because I am not sure how to write it

var string = 'id='+ id ;
var string = 'id='+ id 'USER=1';

Second;
This ajax call below, it post to delete.php to delete a comment, it works but I would like to add in some error handling. Once I add it into the backend, how can I make it show an error in jquery ?

$.ajax({
   type: "POST",
   url: "delete.php",
   data: string,
   cache: false,
   success: function(){
    commentContainer.slideUp('slow', function() {$(this).remove();});
    $('#load').fadeOut();
  }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T09:00:47+00:00Added an answer on May 12, 2026 at 9:00 am

    You’re missing a concatenation operator and an ampersand, also I wouldn’t use ‘string’ as a variable name:

    var str = 'id='+ id + '&USER=1';
    

    That said, ‘string’ is not a JS reserved word, but still seems like bad practice (to me at least).

    What you are passing in your ‘string’ variable to $.ajax is a query string, I would suggest reading this for more information:

    http://en.wikipedia.org/wiki/Query_string

    On your question about error handling, one way is to check the response text for something and act accordingly, e.g.:

    $.ajax({
       type: "POST",
       url: "delete.php",
       data: string,
       cache: false,
       success: function(resp){
        if(resp == 'error') { //get PHP to echo the string 'error' if something bad happened
            alert('There was an error!');
        } else {
            commentContainer.slideUp('slow', function() {
                $(this).remove();
            });
            $('#load').fadeOut();   
        }
       }
      });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there's a couple of questions about this out there but I still
I've seen a couple questions on this but haven't been able to solve it...
I found a couple questions similar to this, but not specifically for .NET projects,
I've posted a couple other questions during this process, but I have a better
I have couple of questions about the javascript for loop. First question: for (i=0;
I've asked a couple of questions here but am still having issues. I'd appreciate
First of all, I want to say sorry for this very big question, but
I'm going to bang out a couple of questions here...first, with NuGet is it
First, I'm going to be submitting a couple of different questions that relate to
So I'm afraid this is another one of those slideshow questions that clutters up

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.