bogdann77 Posted November 15, 2010 Share Posted November 15, 2010 i have the file 1.html: ..... <script src="/libs/jquery-1.3.1.min.js" type="text/javascript"></script> <script type="text/javascript"> var url0='{$url0}'; var url1='{$url1}'; var url2='{$url2}'; var url3='{$url3}'; var OPEN_ON = false; openurls= function(){ if(confirm('Opens all?') && OPEN_ON == false){ OPEN_ON = true; $.ajax({ type: "POST", url: "a1.php", data: { url0: url0, url1: url1, url2: url2, url3: url3 }, contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { window.open(url0); window.open(url1); window.open(url2); window.open(url3); alert(msg); }, error: function(msg) { alert(msg); } }) setTimeout("location.reload(true);",3000) OPEN_ON = false } return false } ........ <strong><br><a href="#" onclick="openurls();return false;">Open all </a></strong> The code from a1.php is <?php $url2=$_POST['url2'] if ($url2=="http://www.yahoo.com"){ $url2="http://google.com"; $return = 'true'; }; $url3=$_POST['url3'] if ($url3=="http://www.yahoo.com"){ $url3="http://google.com"; $return = 'true'; }; ?> After you press the link "Open All" write "[object XMLHttpRequest]" (error). Can anyone help me to send the four variables and after verification of a1.php, to send them back. I am a novice with AJAX. Quote Link to comment https://forums.phpfreaks.com/topic/218715-how-send-and-receive-variable-php/ Share on other sites More sharing options...
bogdann77 Posted November 16, 2010 Author Share Posted November 16, 2010 Nobody can help me? Quote Link to comment https://forums.phpfreaks.com/topic/218715-how-send-and-receive-variable-php/#findComment-1134894 Share on other sites More sharing options...
seanlim Posted November 19, 2010 Share Posted November 19, 2010 var url0='{$url0}'; var url1='{$url1}'; var url2='{$url2}'; var url3='{$url3}'; where are the URLs coming from? Quote Link to comment https://forums.phpfreaks.com/topic/218715-how-send-and-receive-variable-php/#findComment-1136721 Share on other sites More sharing options...
bogdann77 Posted November 20, 2010 Author Share Posted November 20, 2010 from my sql Quote Link to comment https://forums.phpfreaks.com/topic/218715-how-send-and-receive-variable-php/#findComment-1137107 Share on other sites More sharing options...
seanlim Posted November 20, 2010 Share Posted November 20, 2010 According to the jQuery API: error(XMLHttpRequest, textStatus, errorThrown) A function to be called if the request fails. The function is passed three arguments: The XMLHttpRequest object, a string describing the type of error that occurred and an optional exception object, if one occurred. Possible values for the second argument (besides null) are "timeout", "error", "notmodified" and "parsererror". This is an Ajax Event. and success(data, textStatus, XMLHttpRequest) A function to be called if the request succeeds. The function gets passed three arguments: The data returned from the server, formatted according to the 'dataType' parameter; a string describing the status; and the XMLHttpRequest object (available as of jQuery 1.4). This is an Ajax Event. Your error and success functions are only accepting 1 parameter each. Especially for your error function, the first parameter is the XMLHTTPRequest object, resulting in the alert box showing "[object XMLHttpRequest]" Quote Link to comment https://forums.phpfreaks.com/topic/218715-how-send-and-receive-variable-php/#findComment-1137170 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.