Quantcast
Channel: Joomla! Forum - community, help and support
Viewing all articles
Browse latest Browse all 1563

Joomla! 4.x Coding • Re: Ajax in Joom 4.x/5.x

$
0
0
I did a modification to the javascript for testing and output to the console.

I do get a success for

Code:

 console.log('SUCCESS: ' + returndata)
with the following results:

Code:

SUCCESS: [object Object]
and the following error for

Code:

console.log('SUCCESS PARSED: ' + responseData);

Code:

Uncaught SyntaxError: "[object Object]" is not valid JSON

Javascript Test Code

Code:

function testAjax(thisFormData){ document.getElementById('requestStatus').innerHTML = "Sending Data";jQuery(document).ready(function($) {var formData = new FormData($(thisFormData)[0]);  jQuery.ajax({url: 'index.php?option=com_ajax&module=omc_web_request&method=test&format=json',type: 'GET',data: formData,async: false,cache: false,contentType: false,processData: false,success: function (returndata) { // was able to connect to serverconsole.log('SUCCESS: ' + returndata);responseData=JSON.parse(returndata);console.log('SUCCESS PARSED: ' + responseData);//if(responseData['status'] == "good") {document.getElementById('requestStatus').innerHTML = returndata;//alert(responseData['alert']);return false;//} else {//document.getElementById('requestStatus').innerHTML = responseData['message'];//}},error: function (error) {  // was not able to connect to serverconsole.log('ERROR: ' + error);console.log('ERROR2: ' + returndata);document.getElementById('requestStatus').innerHTML = "<p>There was a problem submitting your request.</p><p>"+responseData+"</p>"; }});    });}

Statistics: Posted by tpage68 — Mon Jul 22, 2024 9:26 pm



Viewing all articles
Browse latest Browse all 1563

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>