-2

jQuery function:

function refresh(ppp){
    $("#content").load("process.php"+ppp)
}

PHP process.php:

$vID = $_REQUEST[id];

include page_$vID.php;

The problem is that any code like datatables, jquery stuff doesn't load in the new content. I have to include all .js and .css in this piece of script. And some of the jQuery plugins doesnt work anymore.

What are the best prectices in this case? How do you integrate PHP+jQuery and jQuery's Load()?

Erick Engelhardt
  • 704
  • 2
  • 10
  • 30

2 Answers2

1

lookup $.ajax() might do what you want. http://api.jquery.com/jQuery.ajax/

circusdei
  • 1,967
  • 12
  • 28
0

It's hard to say with the little data you have provided, but my guess is that you are trying to add stuff to the interface that requires some sort of initialization by javascript.

For instance, if you have some content like this:

<input class="datepicker" />

And a plugin that adds a datepicker widget to this input, the widget does not work on dynamically loaded content. This is most likely because you have some code in $(document).ready() that initializes your widgets. This code only runs the first time the page loads however, and not after you load some new dynamically loaded content.

To solve you would have to run the same initialization code found in your document ready code, and run it again after your dynamically loaded content is loaded.

Other than that, I believe JQuery automatically tries to load scripts found in dynamically loaded content, so I'm not sure why that is an issue. Would be helpful to see the actual page content that you are trying to load.

as for dynamically loaded css, see this link: How to apply inline and/or external CSS loaded dynamically with jQuery

Community
  • 1
  • 1
dqhendricks
  • 19,030
  • 11
  • 50
  • 83
  • Thats the point! I have to refresh a datatable (datatable.net) inside a div. But when I load it my prior elements stops working, just the new-loaded one works. – Erick Engelhardt Feb 03 '12 at 12:32
  • @ErickEngelhardt how are you initializing your datatables? where is the code for that and what does it look like? what type of selector are you using to create your datatables? – dqhendricks Feb 03 '12 at 16:42