Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery: accessing an attribute value that has been updated since the page was loaded
    primarykey
    data
    text
    <p>I have 2 jquery functions: the first modifies the value of a particular attribute, and also updates the server-side database so that this value is rendered in future page loads. The second one retrieves the value of this attribute.</p> <p>If the first function is run, and the page is refreshed (so that the value is retrieved from the server and exists in the DOM on pageload), then the second one works as expected, giving the value. However, if the first function is run, but the page is not refreshed, the second function returns an empty string (the original value).</p> <p>To check that something else isn't the problem, if you run the first function, and then inspect the page's source, it exactly matches the source of the refreshed page. However, jquery seems to ignore the updated value and instead retrieve that which existed before being modified.</p> <p>Surely there is some way around this?</p> <p>Many thanks</p> <p>edit: This is how the relevent sourcecode looks when inspecting, regardless of whether you inspect it right after the value is updated using jquery, or after refreshing the page:</p> <pre><code>&lt;input type="hidden" class="answer_key" name="answer_key" value="ahVkZXZ-Y3liZXJuYXV0c3Byb2plY3RyEQsSC1JlYnVzQW5zd2VyGEAM" /&gt; </code></pre> <p>Why, then, does answer_key's value = "" if you don't first refresh the page?</p> <p>edit2: this is driving me insane, can't figure out what the problem is. I recreated the basic functionality in very minimal form here: <a href="http://jsfiddle.net/eX78r/1/" rel="nofollow">http://jsfiddle.net/eX78r/1/</a> but it works as it should, suggesting there is something peculiar going on in my code.</p> <p>With that in mind, here's a link to the whole lot. If anyone can spot what the problem might be, I'd be extremely grateful - I've been stumped on this for most of the day! <a href="http://pastebin.com/enn1Eca4" rel="nofollow">http://pastebin.com/enn1Eca4</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload