ajaxform

jQuery ajaxForm returning .json file

心不动则不痛 提交于 2019-11-30 09:03:34
I've got a model creation form in rails which I also have returning JSON through ajax. My code so far look like: $('#new_stem').ajaxForm({ //#new_stem is my form dataType: 'json', success: formSuccess }); function formSuccess(stemObj) { //does stuff with stemObj } And I have a multipart form with a file uploader (but I'm not sure if that is relevant). When I submit the form it works fine (my models are properly being created and renders as json), but instead of the json getting handled by the formSuccess function, it prompts a download for "stems.json" (the path to my stem creation action) in

Ajax.BeginForm with OnComplete always updates page

北战南征 提交于 2019-11-29 18:38:49
问题 I have simple ajax form in MVC. In AjaxOptions there is OnComplete set to simple javascript function which does one thing - returns false. @using (Ajax.BeginForm("Action", "Controller", new AjaxOptions { UpdateTargetId = "DivFormId", HttpMethod = "Post", OnComplete = "preventUpdate" })) function preventUpdate(xhr) { return false; } The problem is, that page is already updated. E.g. in one case controller returns partial view after postback, in other case it returns some Json object. I want it

jQuery ajaxForm returning .json file

ⅰ亾dé卋堺 提交于 2019-11-29 13:14:33
问题 I've got a model creation form in rails which I also have returning JSON through ajax. My code so far look like: $('#new_stem').ajaxForm({ //#new_stem is my form dataType: 'json', success: formSuccess }); function formSuccess(stemObj) { //does stuff with stemObj } And I have a multipart form with a file uploader (but I'm not sure if that is relevant). When I submit the form it works fine (my models are properly being created and renders as json), but instead of the json getting handled by the

Can i return javascript from MVC controller to View via Ajax request

落花浮王杯 提交于 2019-11-29 11:40:28
I am trying to do like this in ASP.net MVC 2.0 Application. I have a form with two fields number1 and number2. I want add two these two numbers using an ajax request. In the controller, i am recieving two numbers ,adding them and storing result in another string. then, i am doing like this: [HttpPost] public string TestAjax(FormCollection form) { int strnum1 = Convert.ToInt32(form["txtbox1"].ToString()); int strnum2 = Convert.ToInt32(form["txtbox2"].ToString()); string strnum3 = Convert.ToString(strnum1 + strnum2); if (strnum3 != null) { return "<script>alert("some message")</script>"; }

axios post request to send form data

六眼飞鱼酱① 提交于 2019-11-26 10:15:16
axios POST request is hitting the url on the controller but setting null values to my POJO class, when I go through developer tools in chrome, the payload contains data. What am I doing wrong? Axios POST Request: var body = { userName: 'Fred', userEmail: 'Flintstone@gmail.com' } axios({ method: 'post', url: '/addUser', data: body }) .then(function (response) { console.log(response); }) .catch(function (error) { console.log(error); }); Browser Response: If I set headers as: headers:{ Content-Type:'multipart/form-data' } The request throws the error Error in posting multipart/form-data. Content

axios post request to send form data

烂漫一生 提交于 2019-11-26 01:35:57
问题 axios POST request is hitting the url on the controller but setting null values to my POJO class, when I go through developer tools in chrome, the payload contains data. What am I doing wrong? Axios POST Request: var body = { userName: \'Fred\', userEmail: \'Flintstone@gmail.com\' } axios({ method: \'post\', url: \'/addUser\', data: body }) .then(function (response) { console.log(response); }) .catch(function (error) { console.log(error); }); Browser Response: If I set headers as: headers:{