0

I have already seen all the q&a here, and I couldn't fix the problem. I'm trying to send a two character string.

var country_code = 'PT';
  $.ajax({
    url: 'GetData.php',
    type: 'POST',
    data: {'country': country_code},
    dataType: "json",
    success: function(res) {
      ...
    },
    error: function () {                    
      console.log("There was an error");
  }
});

on GetData.php I just have

$cty = $_POST['country'];

$query = "SELECT DISTINCT uuid_client, country FROM users_insertions WHERE country='".$cty."'";
...
echo json_encode($res); 

Though, it doesn’t work. I can't get the string on GetData.php What am I doing wrong?

5
  • 1
    What's the error? try to use die($_POST['country']) and check your console. Commented Apr 17, 2015 at 16:04
  • code works perfectly fine, Where's the problem? Commented Apr 17, 2015 at 16:14
  • I found the problem, really weird. It has to do with the URL as I made some changes in the .htaccess root file: "Given URL is not permitted by the Application configuration: One or more of the given URLs is not permitted by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains." Commented Apr 17, 2015 at 21:05
  • How can the "RewriteEngine On" in .htaccess Apache file affect this issue? Commented Apr 17, 2015 at 21:07
  • Weird stuff from Apache! Commented Apr 17, 2015 at 21:57

2 Answers 2

1

Your code does not have any serious problem, but I think It's better to use data: {country: country_code} instead of data: {'country': country_code}. Maybe this can solve your problem.

Sign up to request clarification or add additional context in comments.

2 Comments

Please inspect your browser's console and tell the result.
Do you mean with Firebug?
0

I found my problem. It was the Apache .htaccess file that was changing the URL to something else. If nothing else works, try checking your .htaccess file.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.