Home > Bad Request > Http Error 400 Ajax

Http Error 400 Ajax


Privacy statement Dev Centers Windows Office More... Plant based lifeforms: brain equivalent? It is working fine now.. Browse other questions tagged javascript jquery ajax or ask your own question. navigate here

How to handle a client's request to work directly for them? use of diodes and resistors in a push-pull amplifier Why was the identity of the Half-Blood Prince important to the story? Letter-replacement challenge Is it possible to create a lighter wallet than simplewallet without giving up a view key? How to put the label in a table's column Proof of 'sandwich theorem' for sequences Conference presenting: stick to paper material?

400 Bad Request In Ajax Call

Why is this step necessary? –JasonTS Mar 17 '15 at 3:11 1 I had exactly the same problem and this is the only place where JSON.stringify() is mentioned. Why did Moody eat the school's sausages? Central europe and the national color black Project upgrade to Winter 16 in Eclipse.

The post was useful. So here's the correct way to do the request: $.ajax({ //actually approve or reject the promotion url: url, type: "POST", data: JSON.stringify({ // Those property names must match the property names of your PromotionDecision view model promotionId: data.PromotionId, userId: data.UserId, reasonText: data.ReasonText }), contentType: "application/json; charset=utf-8", success: function (data) { if (indicator == 'A') { alert('Promotion approved successfully!'); } else { alert('Promotion rejected successfully.'); } var homelink = '<%: Url.Action("Index","Home") %>'; window.location.href = (homelink); returndata = data; }, error: function (xhRequest, ErrorText, thrownError) { alert("Failed to process promotion correctly, please try again"); console.log('xhRequest: ' + xhRequest + "\n"); console.log('ErrorText: ' + ErrorText + "\n"); console.log('thrownError: ' + thrownError + "\n"); } }); Notice how I am using the JSON.stringify method that is natively built-into modern browsers to ensure that the JSON being sent to the server is correctly and all values are properly encoded. Large shelves with food in US hotels; shops or free amenity? Post 400 Error Handling multi-part equations Show that a nonabelian group must have at least five distinct elements Is a Ruling Automatically Also a Houserule?

How to tell if a newly built bicycle wheel is safe to ride? Jquery Ajax Handle 400 To emailaddress: To name: From name: Extra information in the email body (optional): Email: I am sending you the codedump of Getting 400 bad request error in Jquery Ajax POST that you can see here: https://codedump.io/share/wmK1lmAbjXAV/1 Close Send email Share Sign up Sign up with GitHub Email: Displayname Password: Repeat password: Tags jquery ajax post http-status-code-400 Latest added frame Popup-2 Popup popup se1ue02aufgabe3 Terms & services -Privacy -Rss Sign in -Sign up For programmers by programmers Tag v2.0.1 Github · Twitter · Facebook · Guide · Class Reference · Guide 2.0 · API 2.0 · Wiki · Extensions · Live Chat About About Yii Features Performance License Contact Us Downloads Framework Extensions Demos Logo Documentation Take the Tour Tutorials Class Reference Wiki Guide 2.0 Class Reference 2.0 Screencasts Resources Development Contribute to Yii Latest Updates Report a Bug Report a Security Issue Community Forum Live Chat News Hall of Fame Badges search Yii Framework Forum: $.ajax Post Return Error 400 Bad Request - Yii Framework Forum Jump to content Sign In » New user? Why is it needed? –WoJ Feb 9 at 10:22 add a comment| up vote 1 down vote You need to build query from "data" object using the following function function buildQuery(obj) { var Result= ''; if(typeof(obj)== 'object') { jQuery.each(obj, function(key, value) { Result+= (Result) ? '&' : ''; if(typeof(value)== 'object' && value.length) { for(var i=0; ihttp://stackoverflow.com/questions/29503984/ajax-call-error-status-of-400-bad-request What are cell phone lots at US airports for?

I changed my POST JSON tobe wrapped with a single quotes. 400 Bad Request Post Method What is it that I am doing wrong? Any idea what I might be doing wrong? $.ajax({ type: 'GET', url: 'http://www.bloomapi.com/api/search?offset=0&key1=last_name&op1=eq&value1=LIN&key2=first_name&op2=eq&value2=JOHN', dataType: 'jsonp' }).done(function(server_data) { console.log(server_data) }).fail(console.log("failed")); javascript jquery ajax share|improve this question asked Apr 8 '15 at 0:46 john c 15112 1 Maybe the server doesn't support JSONP. –Musa Apr 8 '15 at 0:49 brian's answer here looks right to me. Op-amp theory vs practice: what have I done wrong What happens if one brings more than 10,000 USD with them into the US?

Jquery Ajax Handle 400

Here is my code: $.ajax({ type: 'POST', url: "http://localhost:8080/project/server/rest/subjects", data: { "subject:title":"Test Name", "subject:description":"Creating test subject to check POST method API", "sub:tags": ["facebook:work", "facebook:likes"], "sampleSize" : 10, "values": ["science", "machine-learning"] }, error: function(e) { console.log(e); } }); It Says: Can not build resource from request. find this Expanding on Andrea Turri answer to reflect updated jQuery API and .success/.error deprecated methods. 400 Bad Request In Ajax Call more hot questions question feed default about us tour help blog chat data legal privacy policy work here advertising info mobile contact us feedback Technology Life / Arts Culture / Recreation Science Other Stack Overflow Server Fault Super User Web Applications Ask Ubuntu Webmasters Game Development TeX - LaTeX Programmers Unix & Linux Ask Different (Apple) WordPress Development Geographic Information Systems Electrical Engineering Android Enthusiasts Information Security Database Administrators Drupal Answers SharePoint User Experience Mathematica Salesforce ExpressionEngine® Answers Cryptography Code Review Magento Signal Processing Raspberry Pi Programming Puzzles & Code Golf more (7) Photography Science Fiction & Fantasy Graphic Design Movies & TV Music: Practice & Theory Seasoned Advice (cooking) Home Improvement Personal Finance & Money Academia more (8) English Language & Usage Skeptics Mi Yodeya (Judaism) Travel Christianity English Language Learners Japanese Language Arqade (gaming) Bicycles Role-playing Games Anime & Manga more (18) Mathematics Cross Validated (stats) Theoretical Computer Science Physics MathOverflow Chemistry Biology Computer Science Philosophy more (3) Stack Apps Meta Stack Exchange Area 51 Stack Overflow Careers site design / logo © 2016 Stack Exchange Inc; user contributions licensed under cc by-sa 3.0 with attribution required rev 2016.10.17.4097 Stack Overflow works best with JavaScript enabled current community chat Stack Overflow Meta Stack Overflow your communities Sign up or log in to customize your list. Post 400 Bad Request Angularjs This isn't too big of a problem though, if you're on a SharePoint page you there is a hidden form element containing this information -- it has the ID: __REQUESTDIGEST Change your headers object to: headers: { "Accept": "application/json;odata=verbose", "X-RequestDigest": $('#__REQUESTDIGEST').val() } share|improve this answer answered Dec 9 '14 at 16:11 John-M 4,6122729 add a comment| up vote 0 down vote The ajax call was correct, the error was because of my SharePoint field type:text, changed it to number, now it works.

I am able to get the JSON data when I do CURL in the terminal: curl -X GET 'http://www.bloomapi.com/api/search?offset=0&key1=last_name&op1=eq&value1=LIN&key2=first_name&op2=eq&value2=JOHN' For the purpose below - I just hardcoded in the params into the URL. check over here However, bloomapi appears to not like this: jQuery111207365460020955652_1428455335256({"name":"ParameterError","message":"_ are unknown parameters","parameters":{"_":"is an unknown parameter"}}); To get around this, you can disable cache busting like so: $.ajax({ type: 'GET', url: 'http://www.bloomapi.com/api/search?offset=0&key1=last_name&op1=eq&value1=LIN&key2=first_name&op2=eq&value2=JOHN', dataType: 'jsonp', cache: true }).done(function(server_data) { console.log(server_data) }).fail(console.log("failed")); You will have to be careful of how else you break the cache if that's an issue; the api provider may be able to provide feedback on how to do this. This leads me to believe that you are somehow attempting to consume the result of an asynchronous AJAX request outside of the success callback which is not possible. Should a spacecraft be launched towards the East? 400 Bad Request Ajax Spring Mvc

Browse other questions tagged ajax jquery or ask your own question. share|improve this answer edited Jan 11 '13 at 15:58 answered Jan 11 '13 at 15:50 Darin Dimitrov 691k16225062379 yeah I figured it was broken somehow and that code above is what happens after you've been working on it for two straight hours and have gotten increasingly frustrated. In the future, you can easily check the errors you are receiving/what you are sending using a web debugger; I used Fiddler to figure this out. http://orgias.org/bad-request/http-400-error-ie7.html Should a spacecraft be launched towards the East?

Chebyshev Rotation When does bugfixing become overkill, if ever? 400 Bad Request Post Json http://devnote.stokemaster.com/2013/03/jquery-ajax-port-to-rest-wcf-returns.html Saturday, July 20, 2013 6:18 AM Reply | Quote 0 Sign in to vote Hi Peter, Thanks for the response. In fact few of my fields are of type date so I used Date( ) method while passing to ajax call.

Edited by K.Srinivasarao Friday, July 19, 2013 12:46 PM body changing Friday, July 19, 2013 11:58 AM Reply | Quote 1 Sign in to vote Hi, please check and try the points demonstrated in this blog for your service and client.

And if you need to support browsers from the stone age, you could include the json2.js script to your page which will define the JSON.stringify method. comment:3 Changed 5 years ago by addyosmani Keywords neededdocs added; needsdocs removed Docs updated: ​http://api.jquery.com/jQuery.ajax/ Note: See TracTickets for help on using tickets. Help Search Advanced ForumsMembers Yii Framework Forum > Yii 1.1.x > General Discussion View New Content Page 1 of 1 You cannot start a new topic You cannot reply to this topic $.ajax Post Return Error 400 Bad Request Rate Topic: #1 freshuser Junior Member Group: Members Posts: 52 Joined: 19-June 12 Posted 24 September 2012 - 03:00 AM Hi, I have this controller function generated by gii public function actionDelete($id) { if(Yii::app()->request->isPostRequest) { // we only allow deletion via POST request $this->loadModel($id)->delete(); // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser if(!isset($_GET['ajax'])) $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); } else throw new CHttpException(400,'Invalid request. Http Post Bad Request asked 1 year ago viewed 13796 times active 1 year ago Blog Stack Overflow Podcast #91 - Can You Stump Nick Craver?

When does bugfixing become overkill, if ever? Once you get that figured out.... So the correct version is here: $.ajax({ type: 'POST', url: "http://localhost:8080/project/server/rest/subjects", data: JSON.stringify({ "subject:title":"Test Name", "subject:description":"Creating test subject to check POST method API", "sub:tags": ["facebook:work", "facebook:likes"], "sampleSize" : 10, "values": ["science", "machine-learning"] }), error: function(e) { console.log(e); }, dataType: "json", contentType: "application/json" }); May be it will help someone else. http://orgias.org/bad-request/http-400-error-fix.html Merge sort C# Implementation Why is a lottery conducted for sick patients to be cured?

The use of each key in Western music Are there infinite number of sizes of gaps between primes? What happens if one brings more than 10,000 USD with them into the US? Browse other questions tagged jquery ajax odata or ask your own question. Term describing self-detriment for personal gain How can I Avoid Being Frightened by the Horror Story I am Writing?

Here is my code: $.ajax({
type: 'POST',
url: "http://localhost:8080/project/server/rest/subjects",
data: {
"subject:title":"Test Name",
"subject:description":"Creating test subject to check POST method API",
"sub:tags": ["facebook:work", "facebook:likes"],
"sampleSize" : 10,
"values": ["science", "machine-learning"]
error: function(e) {
It Says: Can not build resource from request. In fact few of my fields are of type date so I used Date( ) method while passing to ajax call. Related 1How to make jQuery AJAX request with a HTTP Handler in SP10?1SharePoint 2013 Rest API OData Query0Ajax CAML Query 400 Bad Request2How to use jQuery and OData to expand multi user field in SharePoint 2013?1Get the permission list for a group using jQuery AJAX requests REST API0Ajax 400 Bad request problem3AJAX Request not firing at Document.Ready0OData batch request does not work well0using rest and ajax , i need to get admin field,which has creator name5Post JSON ajax request with cors not working in IE10/Edge Hot Network Questions How do we ask someone to describe their personality? IQ Puzzle with no pattern Can a GM prohibit players from using external reference materials (like PHB) during play?

Browse other questions tagged jquery post asp.net-mvc-4 or ask your own question.