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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:52:16+00:00 2026-06-13T14:52:16+00:00

I have the following ajax call in a function, which is called upon a

  • 0

I have the following ajax call in a function, which is called upon a clickevent.

$.ajax({
  url:"server.php",
  type:'GET',
  data: {'action':'addEvent'},
  success: function(response)
  {
    if(response)
    {
    alert("200 ok");                
    }
 },
 error: function(xhr, ajaxOptions, ThrownError)
 {
   alert("Error:" + ThrownError);
   $("#output").text("Error: "+ThrownError);
 }
}); 

The php side is as follows.

  if(isset($_GET["action"]))
   {
      $action = $_GET["action"];
     if($action == 'addEvent')
     {
          echo("ping");
     }

   }

Now it throws an error. But the error message i get is :

Exactly, i get Error:

It is driving me crazy.

Also i put in my document.ready, to let it act as some sort of ping, and it worked perfectly

  • 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-06-13T14:52:18+00:00Added an answer on June 13, 2026 at 2:52 pm

    Take a look at this jsFiddle. I’m getting there same error you have.

    Why that is happening there: link is clicked and ajax request is sent. But default action is not stopped and browser navigates to url specified in href and stops any JS execution. AJAX call is stopped too.

    In order to prevent that, you should do something like this:

    $('a').click(function(e) { 
        $.ajax({
          url:"server.php",
          type:'GET',
          data: {'action':'addEvent'},
          success: function(response) {
            if(response) {
               alert("200 ok");                
            }
          },
          error: function(xhr, ajaxOptions, ThrownError) {
             alert("Error:" + ThrownError);
             $("#output").text("Error: "+ThrownError);
          }
       }); 
       e.preventDefault();//this will not allow browser to move to a different URL
       return false; //alternative to e.preventDefault(). 
    });​
    

    Possibly you have similar problem, but it is hard to notice because your element is causing simple page reload, browser navigates to the same page.

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

Sidebar

Related Questions

I have the following code: $.ajax({ type: 'GET', url: 'index.php?route=checkout/onepagecheckout/getpaypaldata', dataType: 'json', success: function(json)
I have the following code: $.ajax({ async: false, url: 'chart_data.php', data: {'option':'high', 'id':id}, dataType:
I have the following jQuery $.ajax({ type: GET, url: http://f.cl.ly/items/0i1V1L1k2F440L1m2Y0G/pointdata.xml, dataType: xml, success: parseXml
I have the following $.ajax({ type: POST, url: qry_invControl.cfm, data: p_sales_price= + input.val() +
I have the following code: $.ajax({ type: POST, url: url, data: sendable, dataType: json,
I have the following Ajax call which send form data to a page and
I have the following ajax call to webservice to pass json data and get
The problem is the following. We have lots of ajax call via $.ajax function.
I have the following code to make a jsonp call. var contacts; $.ajax({ url:
I have the following simple jquery snippet $(document).ready(function () { $.ajax({ url:myjson.json, dataType: 'json',

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.