当从不同的域调用rest webservice时我如何使用jsonp。因为我的简单json不适用于rest webservice。我如何为ajax调用调用rest webservice。我同时使用jsonp和javascript。服务器响应我只看到firebug 中的浏览器,但如何在我的应用程序中显示它
我的 JS 代码。
function callService() { $.ajax({ type: varType, //GET or POST or PUT or DELETE verb url: varUrl, // 服务数据的位置: varData, //发送到服务器的数据 crossDomain: true, cache: false, async: false, contentType: varContentType, // 发送到服务器的内容类型 dataType: varDataType, // 来自服务器的预期数据格式 processdata: varProcessData, //True or False success: function (msg) {//On Successl service call alert("服务器响应成功!.."); }, error: function (msg) { alert('error' + msg.d); } });} 函数 countryProvinceWCFJSONMulti() {
var head = document.getElementsByTagName('head')[0];
script = document.createElement('script');
script.type = 'JSON';
script.src = "http://192.168.15.213/myservice/Service.svc/GetEvents";
script.type = "text/javascript";
head.appendChild(script);
varType = "GET";
varData = '{"username": "' + "Suhasusername" + '","password": "' + "suhaspassword" + '"}';
varContentType = "application/JSONP; charset=utf-8";
varDataType = "JSONP";
varProcessData = true;
callService();
}