SORU
16 Mayıs 2010, Pazar


Nasıl bir WordPress kullanmak -$.() post=/kullanımı contentType uygulama json?

Kullanırken fark ettim $.() post varsayılan contentType uygulama olduğunu ASP.NET mvc benim kod contentType olması gerektiğinde x-www-form-urlencoded - =uygulamasında jquery//json

(Application/json kullanmak gerekir neden görmek için bu soru: http://stackoverflow.com/questions/2792603/aspnet-mvc-why-is-modelstate-isvalid-false-the-x-field-is-required-when-that)

Nasıl yapabilirim $.() post=application/json contentType göndermek? Ben zaten çok sayıda dolar.değiştirmek istemiyorum() fonksiyonları post,$.() ajax çok zaman alacağı için

Eğer çalışırsam

$.post(url, data, function(), "json") 

Hala=/x-www-form-urlencoded uygulama contentType vardır. Tam olarak "" param olursa contenttype değiştirin yoksa json. json nedir yani

Eğer çalışırsam

$.ajaxSetup({
  contentType: "application/json; charset=utf-8"
});

Çalışıyor ama etkileyen her $.get ve $.ben bu yazı ve bazı kırmak için neden olur.

Çok var davranışını değiştirecek bir şekilde dolar.() post=application/json contentType göndermek için?

CEVAP
16 Mayıs 2010, Pazar


$.ajax({
  url:url,
  type:"POST",
  data:data,
  contentType:"application/json; charset=utf-8",
  dataType:"json",
  success: function(){
    ...
  }
})

Bakın : jQuery.ajax()

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Noam Erez

    Noam Erez

    3 NİSAN 2012
  • Pepsi

    Pepsi

    1 Kasım 2005
  • TopOfTheTech

    TopOfTheTech

    5 NİSAN 2010