0

Hi I am trying to get json from a remote host using this piece of code Example at fiddle,

Here i want to add that i am using jquery cross domain ajax plugin

$("button").click(function() {
jQuery.ajax({
    url: "http://50.116.19.49/rest/user.json",
    type: 'GET',
    success: function(result) {
    $("div").html(result.responseText);
    }
  });
});​

I am using jquery AJAX GET method. The problem is when i try to use POST instead of GET it stops working, Need help.!

Thanks

h_h
  • 1,201
  • 4
  • 28
  • 47

1 Answers1

0

It's possible to limit request by method on server side.

So that doesn't mean If it works with GET than that also must work with POST. As I see your web service doesn't allow origin access for POST method.

Here is an example how it's allowed for different type of request in PHP

<?php
  if ($_SERVER["REQUEST_METHOD"] == "GET")
     header("Access-Control-Allow-Origin: *");
     echo "lan";
  else {
     echo "disabled";
  } 
?>
Okan Kocyigit
  • 13,203
  • 18
  • 70
  • 129