我正在尝试测试AngularJS的post方法,但到目前为止我还没有弄清楚如何让它工作。
这是我的代码段。
parameter = { categoryName: '' }; <- just a dummy parameter purposely set to '' for testing purposes
this.httpService({
method: 'POST',
url: '/svc_templates/svc_fetch_category.php',<- Just echoing some JSON string.
data: parameter
}).then(function (response) {
console.log(response);
我得到的回应如下所示。
似乎对php文件的调用正在进行,但实际数据(JSON)由于某种原因没有返回...
有人可以帮帮我吗?
答案 0 :(得分:0)
确保服务器private DrawerLayout drawerlayout;
private ListView listView;
private String[] sample;
private ActionBarDrawerToggle drawerListener;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_phrismdashboard);
sample=getResources().getStringArray(R.array.sample);
listView=(ListView)findViewById(R.id.drawerList);
listView.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, sample));
listView.setOnItemClickListener(this);
drawerlayout=(DrawerLayout)findViewById(R.id.drawer_layout);
ERROR HERE------> drawerListener = new ActionBarDrawerToggle(this, drawerlayout, R.drawable.drawer_shadow, R.string.navigation_drawer_open, R.string.navigation_drawer_close){
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
Toast.makeText(PHRISMDashboard.this, "On drawer opened", Toast.LENGTH_LONG).show();
}
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
Toast.makeText(PHRISMDashboard.this, "On drawer closed", Toast.LENGTH_LONG).show();
}
};
drawerlayout.setDrawerListener(drawerListener);
}
文件实际上正在使用.php
,例如:
curl
curl -X POST -d @filename.txt http://example.com/svc_templates/svc_fetch_category.php --header "Content-Type:application/json"
包含您要发送的JSON数据。