jQuery Ajax -get JSON data 1 Million rows - javascript

I want to fetch 1 Million rows using jQuery AJAX or data come from server successfully .
but gave me error on client side.
Note:
600000 rows successfully display when the limit increase it give me error.
this is my code
$.ajax({
url: "/Api/Reports/SaleSummaryFlexmonster",
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify(args),
success: function (result) {
if (result.SuccessFlag) {
$("#FlexmonsterLoader").hide();
Flex((result.Data));
}
else
return ShowMessage('No data Found', 'error', 'error');
// return deferred.promise();
},
error: function () {
console.log("Data Loading Error");
}
});
if recode more then 60,000 then this console show and i update question
with screenshot. check this Attachment https://prnt.sc/uyd933
Maybe browser not support greater than 600000 rows.
but not exactly confirm.
If not show then gave me this on console
My question is when limit increase from 600000 then why not show ?
is there any Ajax limit?

Related

how to parse more than 20k numbers json data

I do have api which consists more than 20k data, as of now am able to parse data through ajax script and set the value in list view, but its taking more time and responding slowly .
How can I improve the response ..
Please help.
$.ajax({
url: url,
dataType: "json",
data: ({User: userName,Pass: userPass}),
async: true,
success: function (result) {
$('#work-in-progress').fadeOut(0);
ajax.parseJSON(result);
},
error: function (request,error) {
alert('Network error has occurred please try again!');
document.getElementById("internet_access").innerHTML="No internet access";
}
});

Second Ajax call already populated with success results

I have an Ajax call being made from a button press which returns me some data then goes off and creates a grid. The first time the function is called the Ajax call is made, data is returned and the grid is displayed. Happy Days.
However any subsequent call to the function, where none of the data parameters are changed, result in the Ajax call not being made to the server and the function skips straight to 'success' with the results from the successful call already populated.
Changing any of the 'postParameters' results in a successful Ajax call and the data is refreshed.
function btnClick(){
//blah blah
getGridData();
}
function getGridData() {
var postParameters =
{
SiteID: "#Model.SiteID",
DateFilterFrom: $("#datepickerFrom").val(),
DateFilterTo: $("#datepickerTo").val(),
CustomerFilter: $("#customers").val()
};
$.ajax({
url: "#Url.Action("SalesForecast_Read", "Planning")",
type: "GET",
contentType: "application/json; charset=utf-8",
data: postParameters,
dataType: "json",
success: function (results) {
createHighlights(results.Highlights);
createGrid(results.Entries);
},
error: function (e) {
alert(e.responseText);
}
});
};
I know there must be an important Javascript concept I am missing but I just cant seem to be able to nail it.
Can anyone help put me in the right direction?
Have you tried to disable the cache with:
$.ajax({
url: "#Url.Action("SalesForecast_Read", "Planning")",
type: "GET",
cache: false,
contentType: "application/json; charset=utf-8",
data: postParameters,
dataType: "json",
success: function (results) {
createHighlights(results.Highlights);
createGrid(results.Entries);
},
error: function (e) {
alert(e.responseText);
}
});
Explanations
The cache basically tries to save a call to the server by saving the return value of the calls.
It saves them using a hash of your query as a key, so if you make a second query that is identical, it will directly return the value from the cache, which is the value that was returned the first time.
If you disable it, it will ask the server for every query.
You can add cache: false to your ajax request.
$.ajax({
url: "#Url.Action("SalesForecast_Read", "Planning")",
type: "GET",
contentType: "application/json; charset=utf-8",
data: postParameters,
dataType: "json",
cache:false,
success: function (results) {
createHighlights(results.Highlights);
createGrid(results.Entries);
},
error: function (e) {
alert(e.responseText);
}
});
IE might not listen to you though. For that you can add a field to the POST Parameters, where you add the current time in miliseconds, so even IE does not cache.
try to add this in ur ajax call:
$.ajax({
cache: false,
//other options...
});
This will force the recall of the ajax each time.
For more information please check the following link :
api.jquery.com/jquery.ajax

Ajax post to PHP script that queries MySQL DB every 5 seconds performance/problems?

I have a jQuery ajax function that posts to a PHP script which then retrieves some fields from the database and returns them to the client. The ajax function is run every 5 seconds after a button is clicked:
window.setInterval(function()
{
ajaxCall("lobby");
}, 5000);
The ajax function:
function ajaxCall(param)
{
$.ajax({
url: "script/lobby.php",
type: "post",
dataType: "json",
data: param,
success: function(data, textStatus, jqXHR){
//do stuff with data
},
error:function(jqXHR, textStatus, errorThrown){
//show error
}
});
}
Is this a good way of doing it? I have read somewhere that if done wrongly it may create a backlog of calls. How would I prevent that or is there a better way instead of querying a database every 5 seconds for each user?
Instead of creating an interval, don't start the next call to the server until the previous is completed:
function ajaxCall(param)
{
$.ajax({
url: "script/lobby.php",
type: "post",
dataType: "json",
data: param,
success: function(data, textStatus, jqXHR){
setTimeout(function () {/*Use setTimeout instead of setInterval*/
ajaxCall();/*This will keep getting called until an error is hit*/
}, 5000);
//do stuff with data
},
error:function(jqXHR, textStatus, errorThrown){
//show error
}
});
}
ajaxCall(); /*This starts things off*/
You could experiment with a sliding scale of timings. I'm sure there's a name for it, but initally start at 1 second per check, then after so many "null updates" ie. theres no change, extend out to 5 seconds between checks, then 15 seconds, etc.
When you get a data response that indicates activity, you could then reset the checks to 5 seconds.

Jquery post occasionally not calling success or error function

My host is currently having server issues, making today the perfect day to test what happens when my ajax calls fail.
So I'm finding that when something does go wrong, neither my success or fail function in the following are being called: ( simplified for simplicity's sake ). Currently this will fail completely about one in every 10 times.
I'd like to know how to make sure I can catch all errors in ajax, for example when the server simply doesn't respond, as would be the case today.
myvar = jQuery.post(ajax_object.ajax_url, data, function( response ) {
console.log( 'success!' );
})
.fail(function() {
console.log( 'sad trombone' );
});
You can try these two ways.
$.ajax({
url: ajax_object.ajax_url,
type: 'POST',
async: false,
cache: false,
timeout: 30000,
data : data,
dataType: 'json', // use this if you want json response
error: function() {
return true;
},
success: function(data) {
console.log(data);
}
});
OR $.post(ajax_object.ajax_url, { data:data }, function(response){
console.log(response);
});
first you simply give an echo "hii"; exit; in the page ajax_object.ajax_url so you can test whether it is properly redirect to that page..

AJAX success callback function not called

i'm working with python and js on a simple website.
i'm trying to call a method from the client side and get result, but no matter what i do
success function isnt happening.
this is my JS
$.ajax({
url: "http://127.0.0.1:8000/api/gtest/",
type: "POST",
data: { information : "You have a very nice website, sir."},
dataType: "json",
success: function(data) {
alert ("post is success");
},
error: function(request,error) {
alert(request.responseText);
alert(error);
}
});
this is my server side code
def gtest(request):
jsonValidateReturn = simplejson.dumps({"jsonValidateReturn": "ddddd"})
return HttpResponse(jsonValidateReturn, content_type='application/json', mimetype='application/json')
The server responds to the call -
"POST /api/gtest/ HTTP/1.1" 200 31
tried to go over similar questions here but with no success :\
no matter what I do, only the error function is called.
the error alert is always empty.. no actual message.
I know this is probably a small change but I can't find it.
$.ajax({
url: "http://127.0.0.1:8000/api/gtest/",
type: "POST",
data: {
'information' : "You have a very nice website, sir.",
'csrfmiddlewaretoken': '{{csrf_token}}'
},
contentType: "application/json;charset=utf-8",
dataType: "json",
success: function(data) {
alert ("post is success");
},
error: function(request,error) {
alert(request.responseText);
alert(error);
}
});
i cant upvote mccannf's comment.
The problem was solved by the link he posted, i ran the html code from a file on my pc and i needed to load it from the server so link wont start with file:// but with http://
best regards..

Categories

Resources