php - Simple JQuery AJax Example: Variables -


I have code from the W3 schools, jquery is related to ajax and it has modified a bit:

  & lt ;; DOCTYPE html & gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" & gt; & Lt; / Script & gt; & Lt; Script & gt; $ (Document) .ready (function () {$ ("button"). Click (function () {$ ("# div1"). Load ("test / test.php");});}); & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; By & lt;? $ One = 5; $ B = 5; $ A + $ b = $ c ;? & Gt; & Lt; div id = "div1" & gt; & Lt; H2 & gt; Let's change the jQuery AJAX text   

This is a small line on my test.php:

    

When I click on the button, I can not find anything, just "the answer is:"

I know this stupid is simple, but I Zacro AJAX and no solution can be found to answer this question. This is a real project based problem that is more for my understanding.

Thanks

As mentioned above, you can use jquery load method Can not access the local variable of a page in test.php If you want to pass the value of $ c variable to test.php, you can find it or get it using AJAX and get it.

Please refer to the following example:

Your Customer Routine File:
   ");});}); & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; div id = "div1" & gt; & Lt; H2 & gt; Let's change the jQuery AJAX text   

and your server side file:
  & lt; H2 & gt; The answer is: & lt ;? Php echo $ _GET ['c']; ? & Gt; & Lt; / H2 & gt;    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -