The jQuery command $.post is used to "post" PHP variables asynchronously from the current page without reloading or leaving the current page. Data can then be retrieved from the request and used on the current page.
Questions tagged [jquery-post]
196 questions
45
votes
1 answer
RedirectToAction not working after successful jquery ajax post?
The following does not redirect my page: Here is the MVC code:
[HttpPost]
public ActionResult GoHome()
{
return RedirectToAction("Index", "Home");
}
Here is the ajax post:
$.support.cors = true;
…

xaisoft
- 3,343
- 8
- 44
- 72
37
votes
7 answers
jQuery add CSRF token to all $.post() requests' data
I am working on a Laravel 5 app that has CSRF protection enabled by default for all POST requests. I like this added security so I am trying to work with it.
While making a simple $.post() request I received a…

NightMICU
- 9,000
- 30
- 89
- 121
13
votes
2 answers
How to fail Ajax request in Rails?
When user clicks a specific item, I use jQuery's post method to update something in the database:
$.post("/posts/" + post_id + "/update_something",
{ some_param: some_value },
success_handler);
where update_something looks like…

Misha Moroshko
- 166,356
- 226
- 505
- 746
9
votes
4 answers
jQuery.post not always sending form data
I'm using the jQuery Post function, for example:
var fooVar = true;
var barVar = 1;
var bazVar = "baz";
$.post("url",
{
foo: fooVar,
bar: barVar,
baz: bazVar
},
function(){
alert("success");
}
);
In my…

Curtis
- 101,612
- 66
- 270
- 352
9
votes
4 answers
jquery.post() returns 200 OK from MVC 4 WebAPI, but error-handler is hit
I've got an odd case where my jquery.post returns a code #200 (OK) but the error-handler is hit.
This is my MVC WebAPI serverside code (all it does is returning code #200 OK):
[HttpPost]
public HttpResponseMessage Post(T input)
{
…

Andreas
- 5,501
- 2
- 20
- 23
7
votes
2 answers
How do I get HTTP error response code in Jquery POST
I have a wrapper function used to send requests to a server, I need to do something specific if the server returns a code of 401 and I'm not sure how to get this data
$.mobile.showPageLoadingMsg();
$.post(apiUrl+method,p,function(d) {
…

Brian
- 4,328
- 13
- 58
- 103
7
votes
5 answers
How do I get my textarea to preserve newlines when using jQuery and JSON?
I have a textarea for users to input comments and a button to submit using jQuery’s .post() and JSON:
$('#submit').click(function () {
var comment = {};
comment.Author = $("#author").val();
comment.Email = $("#email").val();
…

Ray
- 12,101
- 27
- 95
- 137
7
votes
1 answer
$.post jQuery faster or slower depending on the browser?
I'm trying to improve my jQuery performance and I've noticed it runs faster in Chrome than in other browsers. Does it make sense when it is just an AJAX call to a PHP file?
In order to test it, I am doing this on a click event:
var startTime = new…

Alvaro
- 40,778
- 30
- 164
- 336
5
votes
2 answers
How to pass authorization header in $.post() method using Javascript?
I want to pass Authorization header while POSTing data to server.
I tried
$.ajax({
url : ,
data : JSON.stringify(JSonData),
type : 'POST',
contentType : "text/html",
dataType : 'json',
success : function(Result) {
…

Umesh Kadam
- 843
- 2
- 7
- 14
5
votes
4 answers
jQuery post() with serialize and array of data
i am unable to get collection value during post in mvc 3.
it is returning null.
$.post("/Work/Post", { vm: $('#myForm').serializeArray(), 'collection': ['a', 'b', 'c'] });
//Or
var data = $('#myForm').serializeArray();
data.push({ name:…

Thulasiram
- 8,432
- 8
- 46
- 54
4
votes
2 answers
How to show jQuery is working/waiting/loading?
How do I show a loading picture and/or message to the user ?
If possible, would I like to know how to make it full screen with grey-dimmed background. Kinda like when viewing the large picture from some galleries (sorry, no example link).
Currently…

Kim
- 2,747
- 7
- 41
- 50
3
votes
4 answers
How to continue form submission after an AJAX call?
I want to validate user entries on a WordPress post upon hitting the submit button, display an error message is there are problems, and submit the form if everything is OK. I have a PHP function that does the checking, returning true if data in…

englebip
- 955
- 1
- 11
- 17
3
votes
2 answers
jQuery.post form submit odd bug firefox only
I've search high and low for an answer to this but unfortunately I'm stuck. The problem is only occuring in Firefox (tested IE, Chrome and Safari also - works fine, no errors of any sort). I'll detail the sequence of events to save posting all my…

LiverpoolsNumber9
- 2,384
- 3
- 22
- 34
3
votes
3 answers
YII: How to pass list of parameters from js to controller and call new view by passing another list?
I am new to yii. I am trying to pass a list of parameters from js to my controller in the event of 'on click' of a button.
My code is (in the view named 'studentReport'):
echo CHtml::submitButton('post' ,array('onclick'=>'js:passParams()', 'type'…

Ram lamsal
- 87
- 8
3
votes
2 answers
Ajax inside a bootstrap popover
I'm stuck with this problem, and I really don't know why it's not working.
If I'm using this code out side of the bootstrap's popover it works, but as soon as I'm using it inside the popover it doesn't work anymore. I mean if the form is submit from…

BaNz
- 202
- 2
- 16