Hi Luca, the instructions that Pofferbacco gave you will definitely work,
however I would suggest not returning javascript from and ajax call unless
its an array, even then, you should probably use JSON or XML when you can. 
Here is my suggestion.  

This part of your code looks fine and will work okay.

function requestCustomerInfo() {
        var sId = $("input#includi").val();
        $.get("page_b.php?query=" + sId, displayCustomerInfo);
}


This next part of your code, the displayCustomerInfo function needs a little
work, first off, the varialbes sText and sStats that are being passed dont
exist from what i can see in your example, second you don't need to check
the status of the request, jquery handles that part in the $.get function. 
Here is how your displayCustomerInfo function should look.
//data is going to be what is returned from pageb, basically it's what you
wanted sText to be.

function displayCustomerInfo(data) {
                $("div#divCustomerInfo").html(data);
}

Now this will work, however, you still have another problem, you probably
shouldn't return a javascript function, on your phppage, you only really
need to output <?=$fld
["id"];?>, then in your displayCustomerInfo function you could do this.

function displayCustomerInfo(data) {
                var newDiv = "<div class='brown-bg'></div>";
               $("div#divCustomerInfo").html(newDiv);
               new LinkedIn.CompanyInsiderPopup("li"+data,"Microsoft");
}

Feel free to send me a private message if you have any questions on this
code i gave you.

-- JMcginnis



Pofferbacco wrote:
> 
> Hello,
> I need your help to solve an issue.
> 
> I have:
> - page a: a page with a form
> - page b: a php page that output a result after a query to the
> database
> 
> I use ajax to do the request to page b and I display the result in
> page a.
> Inside the output there is a javascript script that is not displayed
> in page a after the search.
> I know I have to use eval to let the script work, but I don't know
> where, since jquery (and javascript) is really new for me
> 
> Inside page a I have the following code:
> 
> <script type="text/javascript" src="./js/jquery.js"></script>
> <script src="http://www.linkedin.com/companyInsider?
> script&useBorder=yes" type="text/javascript"></script>
>  <script type="text/javascript">
> //<![CDATA[
> function requestCustomerInfo() {
>       var sId = $("input#includi").val();
>       $.get("page_b.php?query=" + sId, displayCustomerInfo);
> }
> 
> function displayCustomerInfo(sText, sStatus) {
>       if (sStatus == "success") {
>               $("div#divCustomerInfo").html(sText);
>       } else {
>               $("div#divCustomerInfo").html("An error occurred.");
>       }
> }
> //]]>
> </script>
> 
> Inside the output of page b I have this script:
> 
> <div class="brown-bg">" style=" padding-
> left:30px;"></div>
>                 <script type="text/javascript">
>                          new LinkedIn.CompanyInsiderPopup("li<?=$fld
> ["id"];?>","Microsoft");
>                       </script>
> 
> This script is not displayed in page a.
> Where do I have to use eval in order to let this script works??
> 
> Thank you.
> Luca
> 
> 

-- 
View this message in context: 
http://old.nabble.com/jquery%2C-eval-and-javascript-in-Ajax-response-tp26361604s27240p26362651.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to