{"action":"opened","issue":{"url":"https://api.github.com/repos/mangreen/Some-Note/issues/15","labels_url":"https://api.github.com/repos/mangreen/Some-Note/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/mangreen/Some-Note/issues/15/comments","events_url":"https://api.github.com/repos/mangreen/Some-Note/issues/15/events","html_url":"https://github.com/mangreen/Some-Note/issues/15","id":104298305,"number":15,"title":"angular $.post變成option的解決方式","user":{"login":"mangreen","id":3994297,"avatar_url":"https://avatars.githubusercontent.com/u/3994297?v=3","gravatar_id":"","url":"https://api.github.com/users/mangreen","html_url":"https://github.com/mangreen","followers_url":"https://api.github.com/users/mangreen/followers","following_url":"https://api.github.com/users/mangreen/following{/other_user}","gists_url":"https://api.github.com/users/mangreen/gists{/gist_id}","starred_url":"https://api.github.com/users/mangreen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mangreen/subscriptions","organizations_url":"https://api.github.com/users/mangreen/orgs","repos_url":"https://api.github.com/users/mangreen/repos","events_url":"https://api.github.com/users/mangreen/events{/privacy}","received_events_url":"https://api.github.com/users/mangreen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-09-01T16:01:16Z","updated_at":"2015-09-01T16:01:16Z","closed_at":null,"body":"會造成這樣的原因是因為cors(跨網站資源共享)所造成的，我這邊解決的方式，是使用如下的語法，就可以正常發出post的request了\r\n\r\n```\r\n var transform = function (data) {\r\n           return $.param(data);\r\n }\r\n\r\n$http.post(url + '/DCI/GUI/GetReadSearchTrade', params,\r\n               {\r\n                   headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\r\n                   transformRequest: transform\r\n               }).success(function (data) {\r\n               $scope.SearchList = data;  \r\n});\r\n```\r\n重點在於headers的這一段，可以改成如下這樣子。\r\n```\r\nvar transform = function (data) {\r\n            return $.param(data);\r\n}\r\n\r\nvar config = {\r\n            headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\r\n            transformRequest: transform\r\n}\r\n\r\n$http.post(url + '/DCI/GUI/GetReadSearchTrade', params,config).success(function (data) {             \r\n            $scope.SearchList = data;                \r\n});\r\n```\r\n這邊是一個簡單的sample，正常的話$http是得做成factory或service的方式。"}}