JSON发布错误中的iPad UIWebView
Posted
技术标签:
【中文标题】JSON发布错误中的iPad UIWebView【英文标题】:iPad UIWebView in JSON Post Error 【发布时间】:2014-02-14 20:46:18 【问题描述】:有一个 WebMethod。
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string getRez
(
string otelKod,
string dil,
string varisGun,
string ayrilisGun,
string yetiskinSayi,
string cocukSayi,
string odaTip,
string yatakTercih,
string cocukDogumTarih1,
string cocukDogumTarih2,
string cocukDogumTarih3,
string ad,
string mail,
string sehir,
string clubNo,
string soyad,
string telefon,
string uyruk,
string adres
)
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
string hata = "";
string sonuc = "";
try
if ((otelKod != null && otelKod != "") && (dil != null && dil != ""))
ado.addPrm(ref cm, "@otel", otelKod);
ado.addPrm(ref cm, "@dil", dil);
ado.addPrm(ref cm, "@varisGun", varisGun);
ado.addPrm(ref cm, "@ayrilisGun", ayrilisGun);
ado.addPrm(ref cm, "@yetiskinSayi", yetiskinSayi);
ado.addPrm(ref cm, "@cocukSayi", cocukSayi);
ado.addPrm(ref cm, "@odaTip", odaTip);
ado.addPrm(ref cm, "@yatakTercih", yatakTercih);
ado.addPrm(ref cm, "@cocukDogumTarih1", cocukDogumTarih1);
ado.addPrm(ref cm, "@cocukDogumTarih2", cocukDogumTarih2);
ado.addPrm(ref cm, "@cocukDogumTarih3", cocukDogumTarih3);
ado.addPrm(ref cm, "@ad", ad);
ado.addPrm(ref cm, "@mail", mail);
ado.addPrm(ref cm, "@sehir", sehir);
ado.addPrm(ref cm, "@clubNo", clubNo);
ado.addPrm(ref cm, "@soyad", soyad);
ado.addPrm(ref cm, "@telefon", telefon);
ado.addPrm(ref cm, "@uyruk", uyruk);
ado.addPrm(ref cm, "@adres", adres);
if (ado.run(
"INSERT INTO [rezRapor]" +
"([otel]" +
",[dil]" +
",[varisGun]" +
",[ayrilisGun]" +
",[yetiskinSayi]" +
",[cocukSayi]" +
",[odaTip]" +
",[yatakTercih]" +
",[cocukDogumTarih1]" +
",[cocukDogumTarih2]" +
",[cocukDogumTarih3]" +
",[ad]" +
",[mail]" +
",[sehir]" +
",[clubNo]" +
",[soyad]" +
",[telefon]" +
",[uyruk]" +
",[adres])" +
" VALUES " +
"(@otel" +
",@dil" +
",@varisGun" +
",@ayrilisGun" +
",@yetiskinSayi" +
",@cocukSayi" +
",@odaTip" +
",@yatakTercih" +
",@cocukDogumTarih1" +
",@cocukDogumTarih2" +
",@cocukDogumTarih3" +
",@ad" +
",@mail" +
",@sehir" +
",@clubNo" +
",@soyad" +
",@telefon" +
",@uyruk" +
",@adres)"
, cm, ado.cn, null, false, false) != -1)
sonuc = "Basarili";
else
hata = Session["adoSqlError"].ToString();
catch (Exception ex)
hata = ex.Message;
if (hata != "")
return "";
else
return hata;
上面有一个webmethod..
function rezervasyon
(
strOtelKod,
strDilKod,
strVarisGun,
strAyrilisGun,
strYetiskinSayi,
strCocukSayi,
strOdaTip,
strYatakTercih,
strCocukDogumTarih1,
strCocukDogumTarih2,
strCocukDogumTarih3,
strAd,
strMail,
strSehir,
strClubNo,
strSoyad,
strTelefon,
strUyruk,
strAdres
)
var veri =
otelKod: strOtelKod,
dil: strDilKod,
varisGun: strVarisGun,
ayrilisGun: strAyrilisGun,
yetiskinSayi: strYetiskinSayi,
cocukSayi: strCocukSayi,
odaTip: strOdaTip,
yatakTercih: strYatakTercih,
cocukDogumTarih1: strCocukDogumTarih1,
cocukDogumTarih2: strCocukDogumTarih2,
cocukDogumTarih3: strCocukDogumTarih3,
ad: strAd,
mail: strMail,
sehir: strSehir,
clubNo: strClubNo,
soyad: strSoyad,
telefon: strTelefon,
uyruk: strUyruk,
adres: strAdres
;
$.ajax(
type: 'POST',
url: "Servis/services.asmx/getRez",
contentType: 'application/json; charset=utf-8',
dataType: 'json',
cache: false,
data: $.toJSON(veri),
success: function (data, textStatus, jqXHR)
alert($(".onayMesaji").text());
$(".jsonkod").html($.toJSON(veri));
,
error: function (jqXHR, textStatus, errorThrown)
alert(" Error: " + errorThrown);
);
错误 IMG:https://pbs.twimg.com/media/Bgdf1wmIUAAfb4_.jpg
我正在这样做,但是“json parse error unrecognized token '
本地主机没问题..
但是当我上传到服务器项目时出现错误..
和json结果;
"otelKod": "101",
"dil": "en-EN",
"varisGun": "",
"ayrilisGun": "",
"yetiskinSayi": "1",
"cocukSayi": "1",
"odaTip": "108",
"yatakTercih": "Single Bed",
"cocukDogumTarih1": "",
"cocukDogumTarih2": "",
"cocukDogumTarih3": "",
"ad": "",
"mail": "",
"sehir": "",
"clubNo": "",
"soyad": "",
"telefon": "",
"uyruk": "",
"adres": ""
我该怎么办?
问候。
【问题讨论】:
【参考方案1】:只需单步执行代码并检查 json 字符串。可以复制到jsonlint.com查看。
【讨论】:
以上是关于JSON发布错误中的iPad UIWebView的主要内容,如果未能解决你的问题,请参考以下文章
Safari iPhone/iPad 中的 Nan 错误日期
Ipad Portrait 中的 ARSCNView CGAffineTransform 错误
iOS - iPad 的 viewWillTransition 中的 UIScreen 边界错误
UIAlertController 中的 UIPickerView 仅在 iPhone 中正确时在 iPad 中给出错误?
错误 ITMS-90363:“无效的 Info.plist 键。捆绑 MyApp.app 中的键 'CFBundleIcons~ipad'...