Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Javscript is not loading on load function of Jquery

  1. #1
    Join Date
    Jul 2012
    Posts
    197
    Thanks
    54
    Thanked 3 Times in 3 Posts

    Default Javscript is not loading on load function of Jquery

    You have any solution for the following


    $('#content').load('<?php echo site_url(); ?>register #regfgp');

    When iam using the above code and loading the layer #regfgp from page register, iam not getting the JavaScript(<script></script>) embedded in the in the layer #regfgp to my master page. As you know the the load function of jquery excludes the embedded JavaScript in the loading page.

    So I used the following code to call the page by AJAX

    Code:
    $.ajax({   
    type: 'GET',   
    url: '<?php echo site_url(); ?>register ',   
    success: function(data) {$("#content").html(data); },
    
    error: function (XMLHttpRequest, textStatus, errorThrown) { alert("error retrieving content");
      }
     });
    The problem is i can't call the layer #regfgp in URL. Instead of that iam getting the full page <?php echo site_url(); ?>register in the layer #content. Is there any solution to call the #reffgp layer(only) in Master page through AJAX(above coding)
    Last edited by letom; 05-04-2013 at 08:10 PM.

  2. #2
    Join Date
    Jul 2012
    Posts
    197
    Thanks
    54
    Thanked 3 Times in 3 Posts

    Default

    John

    Please note this can be done using

    $('<div/>').html(data).find('layer').html();

  3. #3
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    I've got an idea but I haven't had a chance to work it out. I'll post back later if it works.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,134
    Thanks
    44
    Thanked 3,231 Times in 3,192 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by letom View Post
    John

    Please note this can be done using

    $('<div/>').html(data).find('layer').html();
    If it can be done that way, do it that way.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Jul 2012
    Posts
    197
    Thanks
    54
    Thanked 3 Times in 3 Posts

    Default

    some more additional coding part i have missed when copying that..
    I cannot do it with the above coding part only.
    but it is working fine.

  6. #6
    Join Date
    Jul 2012
    Posts
    197
    Thanks
    54
    Thanked 3 Times in 3 Posts

    Default

    Quote Originally Posted by traq View Post
    I've got an idea but I haven't had a chance to work it out. I'll post back later if it works.
    What is that ?

  7. #7
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    It was actually very similar to that snippet you posted. I had missed exactly what you said in your post (and after John replied, I re-read your post and interpreted it as meaning you'd found a solution). I hadn't quite gotten it to work yet, but I keep trying now that I know you have not found a solution.

    Basically, I was using the .done() method to trigger your .find() call. something like:
    Code:
    $.ajax( 'yourpage.html' ).done(
        function( d ){
            $( d ).html().find( '#yourID' ).appendTo( '#target-container' );
        }
    );
    I think it'll work, but I'm missing something at the moment.

  8. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,134
    Thanks
    44
    Thanked 3,231 Times in 3,192 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by letom View Post
    some more additional coding part i have missed when copying that..
    I cannot do it with the above coding part only.
    but it is working fine.
    So, it is working?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #9
    Join Date
    Jul 2012
    Posts
    197
    Thanks
    54
    Thanked 3 Times in 3 Posts

    Default

    @Adrian ..Informative... but i have not tested the code you posted..Need to check with major browsers also..
    But where is the exception handler in our code? If she is taking a decision, i am not loading for some while, how can we show a error message ..

    ....Please look at my below coding @Jon
    Code:
    function (she) {  
    var $gt = $('<div/>').html(she); 
    $("#cyxhka").html( $gt.find('#istv').html() );}

  10. #10
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by letom View Post
    @Adrian ..Informative... but i have not tested the code you posted..Need to check with major browsers also..
    But where is the exception handler in our code?
    To clarify, I have tested it, and it does not work as-is.

    Referring back to John's question, however, is the code you posted working or not working?

Similar Threads

  1. Replies: 9
    Last Post: 02-14-2013, 06:10 AM
  2. Loading.gif not showing up while images load
    By nansaidh in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 09-27-2010, 12:08 AM
  3. can't run function on page load
    By gib65 in forum JavaScript
    Replies: 2
    Last Post: 07-20-2010, 05:50 PM
  4. load function
    By joecool2005 in forum JavaScript
    Replies: 1
    Last Post: 11-22-2006, 05:55 AM
  5. load function
    By neo_philiac in forum JavaScript
    Replies: 2
    Last Post: 07-22-2006, 11:45 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •