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 7655109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:25:46+00:00 2026-05-31T12:25:46+00:00

I have some ajax requests associated with several elements on my page – when

  • 0

I have some ajax requests associated with several elements on my page – when a user clicks ‘Attach’ or ‘Detach’, it sends an ajax request to initiate said request.

If the user clicks each item right after another before the previous ‘click’s AJAX response is received, the following error is received for the requests after the first one:

Uncaught SyntaxError: Unexpected token d

Upon inspection, this occurs at the following:

Uncaught SyntaxError: Unexpected token d
  $.ajax.success                            addassets.js:217
  f.Callbacks.n                             jquery.js:2
  f.Callbacks.o.fireWith                    jquery.js:2
  w                                         jquery.js:4
  f.support.ajax.f.ajaxTransport.send.d     jquery.js:4

Has anyone seen this error/managed to come up with a workaround?

UPDATE:

I re-ran the code, and it appears that it is scrapping the responses to all requests EXCEPT the last one that was submitted. So if a user clicks 1, 2, 3 – the errors will be received for 1 and 2, and the response for 3 will be received as expected.

Here is my ajax code:

    $.ajax({
        url: '/editor/disconnectattachment',
        cache: false,
        data: datastring,
        type: 'POST',
        success: function( data ) {
            console.log( 'received disconnect' );
            var newData = JSON.parse( data );

            if ( newData.Message.code != 200 ) {

                var newbutton = '<input type="button" value="Detach File" class="classic detach-attachment" docid="' + docid + '" rel="' + relid + '" />';
                $scope.empty().html(newbutton).find('input').uniform();;

            } else {

                var newbutton = '<input type="button" value="Attach File" class="attach-attachment" docid="' + docid + '" rel="' + relid + '" />';
                $scope.empty().html(newbutton).find('input').uniform();;

            }

        }
    });

});
  • 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-31T12:25:47+00:00Added an answer on May 31, 2026 at 12:25 pm

    If multiple asynchronous requests are allowed and you need to wait for a successful response of all of them try wrapping them up in a auto-executable function:

        function abc(param1, param2)
        {
    
    (function(param1,param2){
        $.ajax({
                url: '/editor/disconnectattachment',
                cache: false,
                data: datastring,
                type: 'POST',
                success: function( data ) {
                    console.log( 'received disconnect' );
                    var newData = JSON.parse( data );
    
                    if ( newData.Message.code != 200 ) {
    
                        var newbutton = '<input type="button" value="Detach File" class="classic detach-attachment" docid="' + docid + '" rel="' + relid + '" />';
                        $scope.empty().html(newbutton).find('input').uniform();;
    
                    } else {
    
                        var newbutton = '<input type="button" value="Attach File" class="attach-attachment" docid="' + docid + '" rel="' + relid + '" />';
                        $scope.empty().html(newbutton).find('input').uniform();;
    
                    }
    
                }
            });
    
    
        }
    }(param1,param2);
    

    The above code is not a solution, but at least it will let you receive multiple success responses for multiple ajax request calls.

    And you need to use the params inside where you have the data: datastring etc.

    I hope it helps you someway!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page (View), which sends AJAX queries in some intervals. User can
i work with page using prototype, and i have to add some ajax requests,
I occasionally have some long running AJAX requests in my Wicket application. When this
I have an application in which most requests are submitted via AJAX, though some
I have written some jQuery ajax code where I am sending a request to
I have some pages set up so that they respond only to ajax requests.
i'm using jQuery for sending ajax requests to the server, but i have some
i have a problem, i'm working with jquery and some ajax requests. i'm getting
I have an image, onclick on which I make some ajax requests. I need
I have a TreeView with some nodes inside of it. Whenever the user clicks

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.