Javascript passing a variable to PHP

ngplayground

What I'm trying to do is use the below javascript to pull a php page into my html. This works, but what I need and struggling to do is use javascript to send a variable to php so I can use mysql to send results back.

httpRequest("garage-view-default.php", showdefaultimage);
function showdefaultimage(WIDGET){
    d = document.getElementById('garage-view-default');
    d.innerHTML = WIDGET;
}

function httpRequest(url, callback) {
    var httpObj = false;
    if (typeof XMLHttpRequest != 'undefined') {
        httpObj = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        try{
            httpObj = new ActiveXObject('Msxml2.XMLHTTP');
        } catch(e) {try{
            httpObj = new ActiveXObject('iMicrosoft.XMLHTTP');
        } catch(e) {}
    }
}
if (!httpObj) return;
httpObj.onreadystatechange = function() {
    if (httpObj.readyState == 4) { // when request is complete
        callback(httpObj.responseText);
    }
};
httpObj.open('GET', url, true);
httpObj.send(null);
}
randomizer

You can add a GET value to your url:

garage-view-default.php?key=value

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

PHP JavaScript passing variable

From Dev

Passing a javascript variable into a php variable

From Dev

passing a javascript variable to PHP with xmlhttprequest

From Dev

Javascript Variable passing to PHP with Ajax

From Dev

passing php variable in javascript function

From Dev

Passing a PHP variable into a Javascript funtion

From Dev

Passing Javascript variable to PHP link

From Dev

Passing javascript Variable value to php variable

From Dev

Passing Variable from javascript(Ajax) to PHP

From Dev

Passing php variable to external javascript file

From Dev

Passing variable from php to javascript for use as an ID

From Dev

Passing javascript variable to next php page

From Dev

passing Javascript variable to PHP on form submission

From Dev

Passing a value in inline PHP to a javascript variable

From Dev

Passing PHP variable to a JavaScript hyperlink function

From Dev

Passing a javascript variable to PHP to use with Google Charts

From Dev

Passing of javascript variable data to php variable in the same php file

From Dev

Passing of javascript variable data to php variable in the same php file

From Dev

Passing variable PHP, Javascript location.reload, and HTML input

From Dev

Passing Multi-line PHP variable to Javascript function

From Dev

Passing variable from javascript to php with ajax post method

From Dev

Getting an error passing a php array variable to Javascript function

From Dev

Passing variable from javascript to PHP using ajax in yii

From Dev

Passing PHP variable directly to Javascript, bypassing AJAX, how?

From Dev

passing a JavaScript variable to PHP method without using Ajax

From Dev

Passing a "value" from a select in a form to a php variable with javascript issues

From Dev

Passing a PHP variable to JavaScript to use in jQuery.ajax

From Dev

Passing this variable as reference in php

From Dev

Passing Variable into Callback PHP

Related Related

  1. 1

    PHP JavaScript passing variable

  2. 2

    Passing a javascript variable into a php variable

  3. 3

    passing a javascript variable to PHP with xmlhttprequest

  4. 4

    Javascript Variable passing to PHP with Ajax

  5. 5

    passing php variable in javascript function

  6. 6

    Passing a PHP variable into a Javascript funtion

  7. 7

    Passing Javascript variable to PHP link

  8. 8

    Passing javascript Variable value to php variable

  9. 9

    Passing Variable from javascript(Ajax) to PHP

  10. 10

    Passing php variable to external javascript file

  11. 11

    Passing variable from php to javascript for use as an ID

  12. 12

    Passing javascript variable to next php page

  13. 13

    passing Javascript variable to PHP on form submission

  14. 14

    Passing a value in inline PHP to a javascript variable

  15. 15

    Passing PHP variable to a JavaScript hyperlink function

  16. 16

    Passing a javascript variable to PHP to use with Google Charts

  17. 17

    Passing of javascript variable data to php variable in the same php file

  18. 18

    Passing of javascript variable data to php variable in the same php file

  19. 19

    Passing variable PHP, Javascript location.reload, and HTML input

  20. 20

    Passing Multi-line PHP variable to Javascript function

  21. 21

    Passing variable from javascript to php with ajax post method

  22. 22

    Getting an error passing a php array variable to Javascript function

  23. 23

    Passing variable from javascript to PHP using ajax in yii

  24. 24

    Passing PHP variable directly to Javascript, bypassing AJAX, how?

  25. 25

    passing a JavaScript variable to PHP method without using Ajax

  26. 26

    Passing a "value" from a select in a form to a php variable with javascript issues

  27. 27

    Passing a PHP variable to JavaScript to use in jQuery.ajax

  28. 28

    Passing this variable as reference in php

  29. 29

    Passing Variable into Callback PHP

HotTag

Archive