Wednesday 15 April 2015

jquery - Ajax ( this keyword) success callback issue -


To dynamically generate HTML I'm having trouble using AJAX to add < P> ## ### In the code where the main points are

  • I am using PHP as a back-end, and I I'm sure it's okay because I've debug it. It seems that it has something to do with jquery It seems that the AJAX call does not have the permission to add HTML, but it allows outside.

    Thank you for the help I really appreciate it. Please tell me if there is any misunderstanding and I will make the ASAP clear.

    And I have click events that will add html for SPAN

      $ (document) .ready (function () {// Sort default refresh var selected_skill = $ ('# Order'). (": Selected") search. Text (); sortbisk scale (selected_skill); ##### dynamic & lt; #### # problem ##### ("# feed "). But ('click', '.post', showform); ##### The problem is within this code, where I'm a & lt; span & gt; #####});   

    It seems that Anjing Ajax does not work in a call, but works out of it. Does anyone know why and how I will face this problem?

      function showForm () {// Check that the user is logged into user name = $ ('# user name)'. Val (); Var form_id = "form_comment_" + this.id; Var comment_span = "comment_span_" + this.id; If ($ ("$" + form_id) .length == 0) {// All comments are already $ .ense ({type: "post", url: "ajaxcals.fp"), data: {fpost_id: it .id, xswitch: "SFC"}, data type: "json", error: function (qXHR, text position, error thrown) {console.log (errorThrown);}, success: function (result) {// display comment (Var i = 0; i & lt; result.length; i ++) for the console log (the result [0] .username) {var comments_html = result [i]. Username + ":" + result [i] .comment + "& lt; br & gt;"; $ ("# Span_post_" + this.id) .append (comments_html); // ##### Adding it ##### ("# span_post_" + this.id) .append ("Why does not it add?");}}}); $ ("# Span_post_" + this.id) .append ("This fix adds"); // ##### This appendix fin ##### and other {$ ("#" + comment_span) .remove (); // Remove the element if it already exists} return false; }   

    Basically I have to develop the skills of the dynamic period (where I want to add data to use AJAX)

      function SortBySkill (selected_skill) {$ .jax ({type: "POST", url: "ajax_calls.php", data: {skill: selected_skill, xswitch: "SBS"}, data type: "json", error: function (qXHR , Textstats, error trouvance) {console .log (errorThrown);}, success: function (results) {for (var i = 0; i & lt; result.length; i ++) {// ##### Dynamically generated duration ##### str_post = "" + "& lt; a hr Ef = '' class = 'post' id = '"+ result [i] .id.post +"' & gt; "+" Username: "+ result [i]. Username +" | "+" Steam : "+ Result [i] .steam +" | "+" Skills level: "+ result [i]. + Skill +" & lt; br & gt; + "post:" + result [i] Description: " + + "& Lt; br & gt;" + "Date:" + Result [i] .date + "& lt; bell & gt; & lt; / a & gt; & lt; / period & gt;"; Attachment (str_post);}}});  inside success handler    

    This / Strong> jhxQR object

    You can refer to this Need to save And must use it in Ajax callback

      var self = this; // Save the reference // already $. Ajax ({... success: function () {// displays all comments used $ ("# span_post_" + self.id) .append (}   < P>  Second Approach   

    A better way to use $ .proky to bind the context of implementing it

    Third Appraoch

    You can also pass the context parameter to Ajax

      Data type: "Jason", Reference: This, // succeeded in the list of options Interpretation:    

No comments:

Post a Comment