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

4

1 回答 1

0

可以通过服务器端的方法限制请求。

所以这并不意味着如果它适用GET于,那么它也必须适用于POST. 正如我所见,您的网络服务不允许POST方法的源访问。

这是一个示例如何允许不同类型的请求PHP

<?php
  if ($_SERVER["REQUEST_METHOD"] == "GET")
     header("Access-Control-Allow-Origin: *");
     echo "lan";
  else {
     echo "disabled";
  } 
?>
于 2012-10-21T14:28:11.810 回答