Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET, strange results from javascript AJAX
    primarykey
    data
    text
    <p>I was testing 2 ways(sever and client side) to call javascript AJAX to post a ticket to website and then get a link of ticket number for tracking/edit/etc <code>$('#output').html(a);</code>. However both of them got a different results.</p> <p>Server side button clicked is able to call <code>CreateIsm()</code> and got a link of ticket number <code>$('#output').html(a);</code> but couldn't get and pass textarea value to ticket detail info which it empty or null. The alert message in success function under AJAX was successful</p> <p>Client side button clicked is able to call <code>CreateIsm()</code> but couldn't get a link of ticket number but able to get and pass textarea value to ticket detail info. The alert does not trigger in success function under AJAX and I don't know why. Anyone know why?</p> <p>I want the result is successful pass information to ticket detail from textarea AND get a link of ticket number.</p> <p>Here a javascript function,</p> <pre><code>&lt;script&gt; // global variables id = '&lt;%= AD.NEAt.GetUserID().ToString() %&gt;'; notes = ''; ismClassId = ''; caseType = ''; l1 = ''; l2 = ''; l3 = ''; // Create ISM Ticket $('#ButtonRequest').click(function () { //var textBox = document.getElementById('&lt;%=txt.ClientID %&gt;'); //This Freeze //var textBox = document.getElementById('#txt'); //does not appear in ticket detail //var textBox = $('&lt;%=txt.ClientID %&gt;').val(); //does not appear in ticket detail //var textBox = "Please add the following DNS entries\n"; appear in ticket detail ismClassId = 'DOW31038'; caseType = 'Request'; l1 = 'Request'; l2 = 'Network'; l3 = 'Static IP Address'; //This one worked for client side. To get ip and name! notes = $('#txt').val(); $.support.cors = true; $.ajax({ type: "POST", url: "http://servername/Common/Components/ISM/SubmissionPage.aspx", data: { 'Form_ID': '08.01.7', 'ISM_Class_ID': ismClassId, 'Case_Type': caseType, 'Level_1': l1, 'Level_2': l2, 'Level_3': l3, 'Case_Notes': notes, 'Contact_ID': id }, success: function (data) { //console.log(data); alert("success function called"); var str = data; var ticket = $(str).find("#ticketIDOutput").val(); var hreff = "http://servername/Form/SRApproval/SRApproval.aspx?ticketID=" + ticket; var a = "&lt;a href='" + hreff + "' target='blank'&gt;" + ticket + "&lt;/a&gt; created." $('#output').html(a); }, error: function (jqXHR, textStatus, errorThrown) { $('#output').html("Error creating ISM ticket: " + textStatus + " - " + errorThrown); } }); }); &lt;/script&gt; </code></pre> <p>C# server side execute when user click the button,</p> <pre><code>protected void ButtonRequest_Click(object sender, EventArgs e) { //more codes above //ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "call", "&lt;script&gt;CreateIsm();&lt;/script&gt;", false); } </code></pre> <p>ASPX client-side to trigger when the user click the button,</p> <pre><code>&lt;asp:Button ID="ButtonRequest" runat="server" onclick="ButtonRequest_Click" OnClientClick="return false" UseSubmitBehavior="false" Text="Request" Visible="False" style="height: 26px" /&gt; &lt;br /&gt; </code></pre> <p>The textarea that is suppose to be send to ticket detail info,</p> <pre><code>&lt;asp:TextBox ID="txt" runat="server" visible="False" TextMode="MultiLine" Width=356px Height=200px style="margin-left: 0px"&gt;&lt;/asp:TextBox&gt; </code></pre>
    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.
    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