Quiero enviar una cadena como un parámetro de publicación ajax.
El siguiente código:
$.ajax({ type: "POST", url: "http://nakolesah.ru/", data: 'foo=bar&ca$libri=no$libri', success: function(msg){ alert('wow'+msg); } });No está trabajando. ¿Por qué?
Prueba así:
$.ajax({ type: 'POST', // make sure you respect the same origin policy with this url: // http://en.wikipedia.org/wiki/Same_origin_policy url: 'http://nakolesah.ru/', data: { 'foo': 'bar', 'ca$libri': 'no$libri' // <-- the $ sign in the parameter name seems unusual, I would avoid it }, success: function(msg){ alert('wow' + msg); } });$.ajax({ type: 'POST', url:'http://nakolesah.ru/', data:'foo='+ bar+'&calibri='+ nolibri, success: function(msg){ alert('wow' + msg); } });Veo que no entendieron tu pregunta.
La respuesta es: agregue el parámetro "traditional" a su llamada ajax de esta manera:
$.ajax({ traditional: true, type: "POST", url: url, data: custom, success: ok, dataType: "json" });Y funcionará con parámetros PASADOS COMO UNA CADENA.