Jump to content
MakeWebGames

Recommended Posts

Posted

Hello i have a problem with jquery ive made a modification and uses jquery for posting data to the server and returns data to user side if successful but the problem im having on he page i have values and after i post data to the db with jquery the values on the page dont change how can i make them dynamically change

Example:

Username: Admin

then say i change username to demo u have to refresh the page for the username to change so will be stuck saying admin when username is demo now

is there anyway to dynamically update that value with jquery without refreshing the page thanks.

Posted

Make sure the code for the user name (used the same example as you) is something like:

 

Username: <div id="usernameid">$ir['username']</div>

 

Then when they change there name, it will be something like:

 

var newname = $("#newnameinputid").val()
$("#usernameid).val(newname)

 

This isn't tested, and was done on my iPad, so it may not work strait away, but it is a starting point.

Posted

for html element's, to get the inner html content, you use $.html() like so:

 

var name = $('#elementID').html();
$('#placementID').val(name); //IF ITS A INPUT FIELD
$('#placementID').html(name); //IF ITS AN HTML ELEMENT
  • Like 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...