我jQuery代码是这样的:我的AJAX调用仅在Internet Explorer工作
$(document).ready(function() {
$("input:#baglan").click(function() {
var Type;
var Url;
var Data;
var ContentType;
var DataType;
var ProcessData;
WCFJSON();
function WCFJSON() {
var kullanici = $("input:#ad3").val();
var sifre = $("input:#sifre").val();
Type = "POST";
Url = "http://hacegan:84/SQLbaglantiHACEGAN/Service.svc/GetData";
Data = '{"value": "' + kullanici + '","sifre": "' + sifre + '"}';
ContentType = "application/json; charset=utf-8";
DataType = "json";
varProcessData = true;
CallService();
}
//function to call WCF Service
function CallService() {
$.ajax({
type: Type, //GET or POST or PUT or DELETE verb
url: Url, // Location of the service
data: Data, //Data sent to server
contentType: ContentType, // content type sent to server
dataType: DataType, //Expected data format from server
processdata: ProcessData, //True or False
success: function (msg) { //On Successfull service call
ServiceSucceeded(msg);
},
error: ServiceFailed // When Service call fails
});
}
function ServiceFailed(result) {
alert("basarisiz");
alert('Service call failed: ' + result.status + '' + result.statusText);
Type = null;
varUrl = null;
Data = null;
ContentType = null;
DataType = null;
ProcessData = null;
}
function ServiceSucceeded(result) {
if (DataType == "json") {
resultObject = result.GetDataResult;
alert(resultObject);
}
}
});
我的代码是在Internet Explorer中运行,但是当我将运行在Firefox或Chrome的代码它给连接错误ServiceFailed函数。有了这段代码,我正在访问WCF服务。那么,我如何才能在Firefox和Chrome中使用它?
这是一个写作excaption :-)现在我删除了这个功能,但我的代码是不是在Firefox上运行或铬 – 2013-02-11 07:58:52
'processdata:ProcessData,// True or False'从哪里得到该布尔值。我认为这应该是'processdata:varProcessData,' – Jai 2013-02-11 08:00:27
'input:#baglan'?只需带上ID#'baglan'即可。 (同上)。它看起来像jQuery会忽略':';本身作为一个CSS选择器它是无效的,但jQuery似乎只是忽略它。 – 2013-02-11 08:01:25