How to insert bulk (20,000) json data post in ajax jquery - json

I need Bulk (20,000 Records) json data to post Controller.
I Get This Type Of Error
Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property. Parameter name: input
$.ajax({
type: 'POST',
url: baseurl + 'Masters/AuthMapping/MultiBpsave',
dataType: "json",
data: JSON.stringify(BPR[0]),
contentType: "application/json; charset=utf-8",
async: false,
success: function (data) {
},});

Related

how to pass serialize data and stringified data together in ajax

I have a ajax function where i am passing two objects:
1) serialize form data object
2) complex object
Ajax function:
var temp = sessionStorage.getItem('book');
var viewName = $.parseJSON(temp);
var ViewModel = $("#OffsetBookForm").serialize();
$.ajax({
contentType: "application/json; charset=utf-8",
type: "Post",
url: "#Url.Content("~/Estimate/CreateOrder")",
data: JSON.stringify({ 'OffsetCommonObj': ViewModel, 'obj': viewName }),
dataType: 'json',
success: function (data) {
}
});
And My ActionMethod:
public ActionResult CreateOrder(EstimationOffsetViewModel OffsetCommonObj,
OffsetCostCalculation obj)
{
// do something here..
}
My problem is, the first object in action method i.e-"OffsetCommonObj" is getting null. What am I doing wrong in the code? Please Help..Thanks.

how to return json from groovy please?

My environment is openjdk version "1.7.0_75", tomcat-7.0.82, groovy-2.4.13, jquery-3.2.1.
Now I want use ajax post some data to groovy, and want groovy return json to ajax.
Ajax:
$.ajax({
type: "post",
contentType: "application/json; charset=UTF-8",
url: "edit.groovy",
data: json,
dataType: 'json',
success : function(data) {
console.log('ok');
},
error: function(data) {
console.log('err');
}
});
And edit.groovy:
response.contentType = 'application/json';
out << "{rs: 2}";
My question is, why the log is 'err', is my groovy return a right json type please? How to fix it please?
"{rs: 2}"
Isn't valid json the name had to be in double quotes
'{"rs": 2}'
Just use a builder with a map, and it will be done for you
new JsonBuilder([rs: 2]).toString()

creating an array and sending to ajax

I'm trying to gather information from all of the textareas on my page, and then put that information into an array so I can send to the server via ajax/json.
Although I am not quite sure how to go about doing it.
I'm not sure how to pull the information I need from the
Here is what I have so far:
Example of my HTML
"<textarea id='tbObjective_" + counter + "' name='txtObjective' class='objectives' sequence='" + counter + "'></textarea>"
jQuery:
var objectiveList = [];
$('.objectives').each(function (objective) {
objectiveList.push({
id: objective.id,
sequence: objective.sequence,
text: objective.val()
});
});
$.ajax({
type: "POST",
url: url,
dataType: "json",
data: objectiveList
});
Any help would be appreciated
Thanks
you can proceed with the following procedure. i have used python django and html5 for the purpose
1. make a text box which is hidden and after generating your json document set it in this text box (suppose id of textbox is "submit_json") than use
$("#submit_json").val(JSON.stringify(formData, null, '\t')), // (formData, null, '\t') this is js function that i have written for the ourpose
data = JSON.stringify({"jsonDoc":Generated JSON})
console.log(data);
$.ajax({
url: 'http://127.0.0.1:8000/catchjson/',
type: 'POST',
async: false,
contentType: 'application/json',
data: data,
dataType: 'json',
processData: false,
success: function(data){
alert('Done')
//Goto Next Page
},
error: function(jqXHR, textStatus, errorThrown){
alert("Some Error!")
}
})
Now on server you can catch this json if u have problem creating json from your text box let me know
I often use:
var formData = $("form").serialize();
for posting data over ajax, so maybe you could try:
var textareaData = $(".objectives").serialize();
$.ajax({
type: "POST",
url: url,
dataType: "json",
data: textareaData
});
or alternatively make sure all the fields are in a form element and use the first example.
You can parameterise it with $.param(objectiveList)
see jQuery.param()

how to use $.ajax

when I navigate to
http://localhost:54763/Colorbox/Service.svc/GetCustomers,
I get the json data displayed..
but this on the client side did not generate the json data I need.. why?
$.ajax(
{
type: "POST",
url: "../Service.svc/GetCustomers",
dataType: "json",
data: {},
contentType: "application/json; charset=utf-8",
success: function (json) {
var output = json;
$('#MyTemplateOutput').html(output);
});
}
});
you should try using the full url like so and edit this line:
url: "http://localhost:54763/Colorbox/Service.svc/GetCustomers",
try that and see if you get a response back.

Not Receiving JSON object into my Zend Controller

Am am successfully parsing and sending JSON values from my client for my server side controller to receive and decode
$("#test2").click(function() {
$.ajax({
type: "POST",
url: "<?php echo $this->baseUrl() ?>/expensetypes/add",
data: JSON.stringify(wrapFormValues($('#expensetypes'))),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg){
alert( "Data Saved: " + msg );
}
});
});
However in my controller the code $this->getRequest()->getPost() doesn't seem to receive the JSON object that my client is sending though Firebug clearly shows that my JSON object is being parsed and sent.
What am I missing?
try
print_r($this->getRequest->getParams());
and see what that shows you