Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery send string as POST parameters

Tags:

jquery

ajax

post

I want to send a string as an ajax Post parameter.

The following code:

$.ajax({    type: "POST",    url: "http://nakolesah.ru/",    data: 'foo=bar&ca$libri=no$libri',    success: function(msg){      alert('wow'+msg);    } }); 

Is not working. Why?

like image 701
Mirgorod Avatar asked Feb 18 '11 21:02

Mirgorod


2 Answers

Try like this:

$.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);     } }); 
like image 128
Darin Dimitrov Avatar answered Sep 24 '22 06:09

Darin Dimitrov


$.ajax({     type: 'POST',         url:'http://nakolesah.ru/',     data:'foo='+ bar+'&calibri='+ nolibri,     success: function(msg){         alert('wow' + msg);     } }); 
like image 38
Chakavak Behzad Avatar answered Sep 25 '22 06:09

Chakavak Behzad