PDA

View Full Version : Resolved Javscript is not loading on load function of Jquery



letom
04-29-2013, 07:31 PM
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


$.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)

letom
04-30-2013, 07:42 PM
John

Please note this can be done using

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

traq
04-30-2013, 10:14 PM
I've got an idea but I haven't had a chance to work it out. I'll post back later if it works.

jscheuer1
05-01-2013, 03:33 AM
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.

letom
05-01-2013, 04:55 AM
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.

letom
05-01-2013, 04:56 AM
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 ?

traq
05-01-2013, 02:44 PM
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() (http://api.jquery.com/deferred.done/) method to trigger your .find() call. something like:

$.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.

jscheuer1
05-01-2013, 02:56 PM
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?

letom
05-01-2013, 07:27 PM
@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

function (she) {
var $gt = $('<div/>').html(she);
$("#cyxhka").html( $gt.find('#istv').html() );}

traq
05-01-2013, 07:47 PM
@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?

letom
05-02-2013, 03:34 AM
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?
fine...
@Adrain FYI check Bold letters....
???

letom
05-03-2013, 07:23 PM
Any solution for the following


function (she) {
var $gt = $('<div/>').html(she);
$("#cyxhka").html( $gt.find('#istv').html() );}

If she is taking a decision, i am not loading for some while, how can we show a error message ..

traq
05-03-2013, 09:12 PM
fine...
@Adrain FYI check Bold letters....
???

If you're asking what I mean by that:

Please note this can be done using

$('<div/>').html(data).find('layer').html();
This seems to indicate you found a solution to your problem


some more additional coding part i have missed when copying that..
I cannot do it with the above coding part only.
This seems to indicate that you did not find a solution


but it is working fine.
This seems to indicate that you did.

So, John and I are a little unclear about which part(s) of the code you are still having trouble with - that's what I was trying to ask you.


Now, as for this:

Any solution for the following


function (she) {
var $gt = $('<div/>').html(she);
$("#cyxhka").html( $gt.find('#istv').html() );}
If she is taking a decision, i am not loading for some while, how can we show a error message ..

Is this a new question, or part of your original question?

I'm not sure what you mean by "if she is taking a decision". Are you asking how to show an error message if she cannot be loaded as html, or if you can't find the element with id=istv? This might be what you're looking for:


function( she ){
var istv = $( she ) // create a jQ object from she (presumably an html string)
.find( '#istv' ); // and look for the element with id=istv

if( istv.length > 0 ){ // check the length of the resulting jQ object
$( '#cyxhka' ).append( istv ); // append it to the element id=cyxhka
}
else{
alert( 'no element matching id=istv found' );
}
}

letom
05-04-2013, 07:12 PM
Thanks Mr Adrain

First i have posted a question and none of the people here cannot answer that question.. But i found a solution for my question as myself, To help others and having good conscience i posted its answer in the forum. The code is working fine but,I am looking for an error message what you said..

Moreover i am unclear about other conversations.
Please close this thread...