4
Answers

Need To Click F5 To Get Data When Using jquery ajax call

Iranna G

Iranna G

11y
1.9k
1
Hi All,
I am using jquery-1.10.2.js SharePoint 2013 ,Visual webpart.
I have created wcf service which gives response  in json format in sharepoint and trying to get data by using jquery ajax call  in Visual Webpart
$(document).ready(function () {
$.ajax({
type: "GET",
cache: false, url:"http://siturl/SampleService.svc/EmpInfo"),
contentType: "application/json; charset=utf-8",
dataType: "json",
processData: true,
error: function (jqXHR, textStatus, errorThrown) {
alert("Error occured - " + errorThrown)
},
success: function (data) {
//looping the data
}
});
});
Issue:If user select some value and click on save button the data getting stored in database but not showing in the UI.
If i click f5 the data will refresh on UI.Some times i need to click on f5 2 to 3 times then only the data will refresh.
When i deploy solution,i am not able to see the data.If i refresh again(Cliking f5),then the data will come.Some time i need to click 2 to 3 times on f5.The data is coming correctly but it requires additonal click of f5 to show on the visual webaprt.
 
Please help me
Regards,
Veeresh G
Answers (4)
0
Iranna G

Iranna G

NA 6 1.9k 11y
Hi Jagan

Thanks for your reply.I tried the approach u have said but no luck.
I followed some other link 
http://stackoverflow.com/questions/10269262/jquery-need-to-press-f5-refresh-to-see-content
which says to add  jQuery built cleaner solution
{ $.ajaxSetup({ cache: false }); });
I have tried with this but some times evrthing will work fine but some time again need to click on f5 to get data.

 
Regards,
Veeresh G
0
Jaganathan Bantheswaran

Jaganathan Bantheswaran

NA 21.9k 2.2m 11y
Hi,

The problem might be with the binding part of your ajax success function...

Try with different jquery functions like .html() or .text() to update the UI.
0
Iranna G

Iranna G

NA 6 1.9k 11y
Hi Pranay ,

Thanks for your time and reply.

As suggested by you ,I am allready binding data in success method only but still i need to click f5 for data to load.

Regards,
Iranna G
0
Pranay Rana

Pranay Rana

NA 3.6k 586.5k 11y
Hi,

I m not much aware about sharepoint but I guess you need to write code in "Success" function of jquery to refesh webpart or webpage data.


success: function (data) {
//looping the data
//write code to assign data to part you want to refresh
}