나는 객체를 json 웹 서비스 (asp.net) 이 있다.
내 json 다음과 같습니다.
var markers = { "markers": [
{ "position": "128.3657142857143", "markerPosition": "7" },
{ "position": "235.1944023323615", "markerPosition": "19" },
{ "position": "42.5978231292517", "markerPosition": "-3" }
]};
나는 내 json 을 사용하여 스트린그리피 json2.js 객체에는.
저는 jquery 를 사용하여 迈向 내 웹 서비스.
$.ajax({
type: "POST",
url: "/webservices/PodcastService.asmx/CreateMarkers",
data: markers,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data){alert(data);},
failure: function(errMsg) {
alert(errMsg);
}
});
I am getting 다음 오류:
json ", 잘못된 것들이다.
I have a bunch of com/downloads/global/corporate/iar/esg_prosupport. 게시물 이와 관련해 공통 문제 및 것 같습니다 하지만 내가 정말 아무것도 시도하시겠습니까 문제가 해결됩니다.
이 때 마치 방화범 지정하십시오. 서버에 올라오고 있다.
>. markers% 5b0%5d% 5bposition% 5d = 128.3657142857143, 235.1944023323615, markers% 5b1%5d% 7& & markers% 5b0%5d% 5bmarkerposition% 5d = = = 19& markers% 5b2%5d% 5bposition% 5bmarkerposition% 5b1%5d% markers% & 5bposition% 5d, 5d, 5d = 42.5978231292517, markers% & 5b2%5d% 5bmarkerposition% 5d = - 3
즉 내 웹 서비스 기능을 호출할 수 있다.
[WebMethod]
public string CreateMarkers(string markerArray)
{
return "received markers";
}
당신이 말한 것으로 JSON 데이터를 사용할 수 있지만, 데이터의 json2.js 스트린그리피 게시하기를 로렌코디드 아니지만, 이미 볼 수 있습니다 (이 게시물로의 대한 잘못된 json 프리미티브] 1 왜 json 닫히지만 로렌코디드 중입니다.
var markers = [{ "position": "128.3657142857143", "markerPosition": "7" },
{ "position": "235.1944023323615", "markerPosition": "19" },
{ "position": "42.5978231292517", "markerPosition": "-3" }];
$.ajax({
type: "POST",
url: "/webservices/PodcastService.asmx/CreateMarkers",
// The key needs to match your method's input parameter (case-sensitive).
data: JSON.stringify({ Markers: markers }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data){alert(data);},
failure: function(errMsg) {
alert(errMsg);
}
});
Jquery 는 JSON 문자열이어야 예방하기 위해 가장 중요한 문제는 잘못된 JSON 데이터를 전달하는 데 대해 '자연' 매개변수에서 아닌 javascript 객체여야 도왔으매 jQuery doesn& t # 39, 데이터의 로렌코드 시도합니다.
public class Marker
{
public decimal position { get; set; }
public int markerPosition { get; set; }
}
[WebMethod]
public string CreateMarkers(List<Marker> Markers)
{
return "Received " + Markers.Count + " markers.";
}
또한, [] ',' 표시자가 어레이에서는 동의하십시오 같은 표시자는 수도 있습니다. 이 디시리얼라이저 이스마스 스크리프 체르비시스 할 수 있는 것도 매우 유연하며, 사용 (자바스크리프체리아리처) 에 여러분의 의견을 변환하십시오 데이터 서버 측 유형을 지정할 수 있습니다.
스케쳐내 인코드할 있습니다 먼저 JSON 데이터를 보낼 수 있다.
data: {markers: JSON.stringify(markers)}
jQuery 객체를 JSON 자동으로 변환 또는 배열입니다 수 없습니다.
하지만 난 solaris. 오류 메시지 서비스 대응이 해석하는 비롯됩니다. Json 뒤로를 보낼 텍스트 아니다. JSON 문장열 인클로우저된 큰따옴표로 될 수밖에 없다. 그래서 you& # 39; d 일을 해야만 한다.
return "\"received markers\"";
var markers = [{ "position": "128.3657142857143", "markerPosition": "7" },
{ "position": "235.1944023323615", "markerPosition": "19" },
{ "position": "42.5978231292517", "markerPosition": "-3" }];
$.ajax({
type: "POST",
url: "/webservices/PodcastService.asmx/CreateMarkers",
// The key needs to match your method's input parameter (case-sensitive).
data: JSON.stringify({ Markers: markers }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data){alert(data);},
failure: function(errMsg) {
alert(errMsg);
}
});
내가 너무 발생한 이 번호요 그리고 이건 내 솔루션입니다.
Json 데이터를 분석할 때 발생하는 경우, 비록 잘못된 idfsysobject. 객체에는 알잖나 너회의 json 데이터를 분석할 수 있는 코드가 올바른지 스트린그리피 문자열이어야, 아약스는 전에 받은 迈向 JSON:
$.post(CONTEXT+"servlet/capture",{
yesTransactionId : yesTransactionId,
productOfferId : productOfferId
},
function(data){
try{
var trimData = $.trim(JSON.stringify(data));
var obj = $.parseJSON(trimData);
if(obj.success == 'true'){
//some codes ...
나는 쿼리하지
$("#login-button").click(function(e){ alert("hiii");
var username = $("#username-field").val();
var password = $("#username-field").val();
alert(username);
alert("password" + password);
var markers = { "userName" : "admin","password" : "admin123"};
$.ajax({
type: "POST",
url: url,
// The key needs to match your method's input parameter (case-sensitive).
data: JSON.stringify(markers),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data){alert("got the data"+data);},
failure: function(errMsg) {
alert(errMsg);
}
});
});
Ajax 호출에 의해 desktopplatforms 다음의 자바 웹 서비스 var 매개 변수 = { 필드나미: 필드발루 }; 제슨.스트린그리피 ({데이터: 매개변수})
$.ajax({
dataType : 'json',
type : 'POST',
contentType : 'application/json',
url : '<%=request.getContextPath()%>/rest/priceGroups',
data : JSON.stringify({data : param}),
success : function(res) {
if(res.success == true){
$('#alertMessage').html('Successfully price group created.').addClass('alert alert-success fade in');
$('#alertMessage').removeClass('alert-danger alert-info');
initPriceGroupsList();
priceGroupId = 0;
resetForm();
}else{
$('#alertMessage').html(res.message).addClass('alert alert-danger fade in');
}
$('#alertMessage').alert();
window.setTimeout(function() {
$('#alertMessage').removeClass('in');
document.getElementById('message').style.display = 'none';
}, 5000);
}
});