Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Guys I'm facing with an interesting problem.I have 2 file: ShowRecord.aspx and Ekle.aspx .In Ekle.aspx I have a web form like the pic http://prntscr.com/8tl55z[^]

And In ShowRecord.aspx I have a gridview which I can print values my in database.

http://prntscr.com/8tl5kk[^]

When user press 'Ekle' button on ShowRecord.aspx, I load Ekle.aspx into the div(a label inside the div,you can see from the upper link).

What I want is,when user fill the form and press the submit button,I want to show the changes immediately.To do this first I send a .ajax() post to save record to database,And again do a .ajax() post to print values to screen.

Code always save records to database.But is NOT always show the changes immediately.Sometimes shows and sometimes do not.I don't know what is the problem?Can you enlight me please?
Posted
Updated 5-Nov-18 4:48am
Comments
Mohibur Rashid 21-Oct-15 19:32pm    
Check your caching machanism

Quote:
Code always saves the records to the database.
Which means that the code for ajax is working fine, as it sends the data to other page (or wherever ajax is submitting the data) then the problem comes is that response is not shown.

The problem, any problem that you may encounter in web development is always logged in the console. Press F12 to get the console in developer tools, and see if that event is logged there. Perhaps, in most cases you are not sending anything back, an if...else may change the logic or path of the program.

Anyways, check the console there may be a reason for each and every event. Secondly, in the networking tab, see for the logs of your requests. Each request, along with their status code is shown, see what response was sent from server (if any!). This would help you to bring down the problem into one single logical error that you can solve.
 
Share this answer
 
Comments
harun_119 21-Oct-15 4:03am    
Thanks for your comment Ahmad, I look the status code,and I couldn't see a problem.Could you please help me?

http://prntscr.com/8tlqrc

I add a record with id=7 and it print immediately,after that I added a record with id=8 and it didn't showed.
You need to post some code for anyone to better assist you. Anyway, by reading at your post, sound like the code is firing two request to the server, sometime the save record get there first and sometime the print request reach first (that why it blank). Not clear how your code currently look like or version of jQuery, but you can try to update the code to make sure the first request is completed before firing the second request.

Hint: depending on the jQuery version, wrap the second request in the .done() function.


jQuery.ajax() | jQuery API Documentation[^]
 
Share this answer
 
Comments
Richard Deeming 6-Nov-18 9:17am    
The OP is hopefully not still waiting for an answer three years later. :)

The question got dragged back into the active list by solution #3, which looks like borderline spam to me.
Bryian Tan 6-Nov-18 10:12am    
lol. sorry, didn't paid attention to the date.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900