I was debugging ajax to figure out why it wasn't working and in the developer tools I got this log
XMLHttpRequest cannot load http://'WebsiteInQuestion.php'. No 'Access-Control-Allow-Origin'
header is present on the requested resource. Origin 'http://ServiceHostingMyWebpage.com'
is therefore not allowed access.
I read about XMLHttp in passing but didn't think it was relevant and I honestly have no clue about it.
My code doesn't even have a header and it seems that there is some XML code missing.
Here's my ajax code
<script type="text/javascript">
$(document).ready(function() {
$("#my_form").submit(function(event){
alert ("submited");
event.preventDefault("#my_form");
var post_url = $(this).attr("action"); //get form action url
var request_method = $(this).attr("method"); //get form GET/POST method
var form_data = $(this).serialize(); //Encode form elements for submission
console.log (post_url + "" + request_method + " " + form_data);
$.ajax({
type: request_method,
url: post_url,
data: form_data,
success: function( data ) {
alert (data);
$('#server-results').html(data);
}
});
});
});
and basically all of the HTML
<body>
<form id="my_form" method="post" action="http://comicspot-com.stackstaging.com/ajax-php.php">
<input type="text" id="fullname" name="fname">
<input type="submit" id="submit_post" value="Post" >
</form>
<div id="server-results"></div>
BTW, I checked and the link to ajax-embedded-link and it seems to work, pressing submit activates the javascript code and it correctly collects the data, action and method. It just seems like ajax itself isn't being activated. Most likely the XML problem.