0

Is it possible to send input via ajax to a php script and have the success callback .load a section of the already displayed page and have a php script inside the reloaded section display a SESSION variable inside the label of the input?

EDIT: So this is the script I feel like was implemented wrong what errors would you have me fix?

$(document).ready(function() {

$('input1').on('keypress',function(e){
 var p = e.which;
 if(p==13){

        var input1set = $(this);
        var input1 = input1set.serialize();

        $.ajax({ 
            url:'inputs.php',
            type: 'post',
            data: input1,
            success: function(input1) {
                $('#input1lable').load("tables/table_1.php #input1lable");
            }
    });

    return false;

});

// this is the repeatable input field code.

});

So where did I go Wrong?

P.S I hope there is enough context already given to know how this is working in my APP.

Gdfelt
  • 161
  • 15
  • Yes, do you have some code which is not quite working right? – MonkeyZeus Jul 25 '16 at 19:05
  • Yes. when I load a section of php into my page after a background php script gets data from a data base, based off of an input it works, but when that php page section loads a new set of javascript into the page, and try what I explained above within this new section when I hit enter the entire page reloads and I have to re do everything. – Gdfelt Jul 25 '16 at 19:17
  • It sounds like you are having an event delegation issue. Take a look at [Event binding on dynamically created elements](http://stackoverflow.com/q/203198/2191572) and make sure to use the `.on()` function. – MonkeyZeus Jul 25 '16 at 19:22
  • Thanks for the link. I'll take a look and report back on whether my issue was resolved. – Gdfelt Jul 25 '16 at 19:27
  • 1
    You're welcome, if you find it helpful then please feel free to update your question and post your code but try to limit it to the absolute least amount of code necessary to reproduce the problem. – MonkeyZeus Jul 25 '16 at 20:03

0 Answers0