Amazing Aaron Amazing Aaron - 2 months ago 5x
Ajax Question

How to doPastBack on an AJAX Response

I am getting a html page with GET and it contains this element:

<a id="ctl00_cphRoblox_ClaimOwnershipButton" href="javascript:__doPostBack('ctl00$cphRoblox$ClaimOwnershipButton','')">Claim Ownership</a>

i want to do the action in the href attribute

how would i do this please?

var hrefValue = document.getElementById("ctl00_cphRoblox_ClaimOwnershipButton").href;

var hrefSplit = hrefValue.split("'");

var hrefArgument = hrefSplit[1];

  1. Extract the href attribute from the anchor.
  2. Split the href by ' separator, which makes an array like:

    ["javascript:__doPostBack(", "ctl00$cphRoblox$ClaimOwnershipButton", ",", "", ")"]

  3. Take the 2nd item (index 1)

  4. Execute the function (which I guess never changes) with the extracted argument.