我有在服务器中发布数据的代码,这是我的代码
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("phone", mPhoneNumber));
params.add(new BasicNameValuePair("prod_title", nama));
params.add(new BasicNameValuePair("prod_desc", des));
JSONObject json = jsonParser.makeHttpRequest(Constants.url_create_product, "POST", params);
// check log cat from response
Log.d("Create Response", json.toString());
try {
int success = json.getInt(Constants.TAG_SUCCESS);
if (success == 1) {
// successfully created user
Intent i = new Intent(getApplicationContext(), shoop3Activity.class);
i.putExtra("phone", mPhoneNumber);
startActivity(i);
// closing this screen
finish();
} else {
// failed to create user
Toast.makeText(getApplicationContext(),"Gagal bikin user", Toast.LENGTH_LONG).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
但它显示这样的错误
10-08 12:36:11.857: INFO/ActivityManager(59): Displayed activity shoop3.android.edu/.Activity3: 1074 ms (total 1074 ms)
10-08 12:36:16.037: ERROR/JSON Parser(881): Error parsing data org.json.JSONException: Value <div of type java.lang.String cannot be converted to JSONObject
10-08 12:36:16.037: DEBUG/Create Response(881): {"status":1}
10-08 12:36:16.127: INFO/ActivityManager(59): Starting activity: Intent { cmp=shoop3.android.edu/.setupstoreActivity (has extras) }
10-08 12:36:17.507: INFO/ActivityManager(59): Displayed activity shoop3.android.edu/.setupstoreActivity: 1191 ms (total 1191 ms)
请问有什么解决办法吗??它显示错误解析数据...字符串无法转换为 JSonObject