Ask questions and get good answers on jQuery

I am looking for a way to dynamically send php variables into the 'content' section of the ajax call for a container.

For example a user enters two items into a form and clicks send, a function appends user input onto a php url like so: my_php_page?itemone=what&itemtwo=when and some ho inserts this into the ajax call 'content' for a particular container returning the processed php into the open container

any ideas? thank you

asked Jan 19 '10 at 16:33

denelius's gravatar image

denelius
593

edited Sep 18 '10 at 16:37

Matteo%20Bicocchi's gravatar image

Matteo Bicocchi ♦♦
1776129


There's a method to change the container content dynamically via Ajax:

 jQuery.fn.mb_changeContent= function(url, data)

where url is your php page and data the params you can pass. For example:

you have a container with an ID="myContainerPlus"

var myData={

itemone: $("myInput1").val(),
itemtwo: $("myInput2").val()

}

$("#myContainerPlus").mb_changeContent("my_php_page", myData);

This should load your page passing the params.

answered Jan 19 '10 at 19:05

Matteo%20Bicocchi's gravatar image

Matteo Bicocchi ♦♦
1776129

Matteo, thank you for your prompt response, the params are passed and loaded however the window container disappears ...so only the passed params are displayed (text) floating on the page with no means to dock close or re-size. I am able to drop and drag the text and there seems to be a hidden frame around it. Any ideas? thank you

(Jan 20 '10 at 15:16) denelius

Hi guys, Matteo, i have the same problem.

when i use :

$('#demoContainer').mb_changeContainerContent('_intro_negocio.php', 'idnegocio=' + $('input#idnegocio').val() + '&desnegocio=' + $('input#desnegocio').val());

the page "_intro_negocio.php" make an "insert into a DB", and then returns :

"Insert ok"

The DB is affected, one row with the parameters is inserted, but.. the container closes itself insantly.

may you help me ?

Thanks so much.

(sorry for my english, im from Honduras)

answered Sep 16 '10 at 03:48

Dennis%20Garcia's gravatar image

Dennis Garcia
111

Hi Dennis, I don't know why the container is closing... do you have any error on console? the function you are using makes an ajax call and return the result into the ".mbcontainercontent:first" of the container... nothing else... you should have "Insert ok" as content of your container... Do you have a public URL where to see your behavior?

(Sep 18 '10 at 16:45) Matteo Bicocchi ♦♦

The above mentioned problem of the container 'disappearing' seems to be related to the Ajax call replacing the entire container params {buttons:'m,i,c', icon:'browser.png', skin:'white', ... etc with the response, I stand to be corrected but at a guess i would say these are loaded up when the page loads so when the Ajax call is made these are somehow not given an opportunity to load. My knowledge of jQuery is not good enough at this stage to apply a working solution however I would assume that in the Ajax return there is a need to somehow rebuild the class params or refer back to original params and get them loaded.

I have come up with a work around in the following:

function makeAjaxCall()
{
   var evt = "myvargoeshere";

$.get("processmyvar.php", { myvar: evt },
     function(data){ //response from ajax call
     document.getElementById('mydiv_id').innerHTML = data; // places response in div
   })
 }

If anyone has any comments or is able to clarify my understanding on any of the aforementioned methods I would be most grateful. thank you

answered Jan 22 '10 at 21:17

denelius's gravatar image

denelius
593

It's my fault... the function you have to use to change the content is: jQuery.fn.mb_changeContainerContent(url,data) and not jQuery.fn.mb_changeContent(url,data) as I mentioned above...

the complete code is:

var myData={

itemone: $("myInput1").val(),
itemtwo: $("myInput2").val()

}

$("#myContainerPlus").mb_changeContainerContent("my_php_page", myData);

Sorry :-)

answered Sep 18 '10 at 16:33

Matteo%20Bicocchi's gravatar image

Matteo Bicocchi ♦♦
1776129

edited Sep 18 '10 at 16:35

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×9
×1

Asked: Jan 19 '10 at 16:33

Seen: 683 times

Last updated: Sep 18 '10 at 16:45

jQuery main site - Matteo Bicocchi