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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:50:14+00:00 2026-06-06T21:50:14+00:00

I have this server side SLIM code: require ‘Slim/Slim.php’; $app = new Slim(); //$app->config(‘debug’,

  • 0

I have this server side SLIM code:

require 'Slim/Slim.php';

$app = new Slim();
//$app->config('debug', true);
$app->get('/hello', 'hello');
//$app->post('/addConsultant', 'addConsultant');
$app->run();

function hello() {
    echo '{"hello": ' . json_encode("merp") . '}';
}

Pretty bare bones right? I mean it is only one single GET.

Now, I have this client side Javascript code:

var rootURL = "http://somabsolutions.se/dev/index.php/";

$('#btnHello').click(function() {
    $.ajax({
        type: 'GET',
        url: rootURL + '/hello',
        dataType: "text json",
        success: function(data){
            alert("Something " + data);
        },
        error: ajaxFailed
    });

    return false;
});

function ajaxFailed(XMLHttpRequest, textStatus, errorThrown) {
    alert("XMLHttpRequest=" + XMLHttpRequest.responseText + "\ntextStatus=" + textStatus     + "\nerrorThrown=" + errorThrown);
}

Also pretty easy.

I have this HTML stuff, which holds the button that is bound to the AJAX call by jQuery:

<!DOCTYPE HTML>
    <html>
        <head>
            <title>
                Backend test
            </title>
        </head>
        <body>
            <form id="testForm">

                <button id="btnHello">Hello World</button>

            </form>
            <script src="javascript/jquery-1.7.2.min.js"></script>
            <script src="javascript/main.js"></script>
        </body>
     </html>

This stuff, used to work, until today, when it for some alien reason stopped doing so!

See, it works, right?

But every time I press that HTML button, Ajax thinks the call fails and redirects me to the error function, which fails to provide me with anything but blank error messages.

What is wrong with this? It worked just fine some days ago!

  • 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-06T21:50:16+00:00Added an answer on June 6, 2026 at 9:50 pm

    Okay now I definitively know what was wrong, the problem was that I tried to do the REST call to an URL that was different than from the one was currently on, I was trying to call http://something.com/argument from http://www.something.com/argument

    Apparently, this is enough for JavaScript to think that it is a cross domain call, which it is really not.

    There is a parameter in JQuery –

    jQuery.support.cors = true;
    

    That is supposed to allow cross domain calls, or at least what javaScript thinks to be cross domain calls, but it did nothing for me. I just have to make sure that the REST calls are from the correct URL.

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

Sidebar

Related Questions

i have this code on the server side: <?php header('Content-Type: text/html; charset=utf-8'); require ../general.variables.php;
On server side I have this code which running in new thread static void
My project setup is like this Server side I have webserver with PHP,MySQL database
I have a chrome extension which have a server-side javascript and I need this
I have this mySQL code that connects to my server. It connects just fine:
I have this horribly stripped delphi code that basically login to server, save cookie
I have this code to create a webapp in my server: import web urls
I am developing a Facebook app. I have a server side OAuth flow which
I have this GWT application which login/logout to a server. The server side is
Is there any ToDo app that have .NET api for server side adding tasks.

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.