i am trying to send the contents of an input box to a php file via JQuery/AJAX. When the script runs, all seems well, however, I receive nothing back. The following is my ajax call;
$(document).ready(function(){
$("#kinaseEntry").change(function () {
var kinaseEntry = $("#kinaseEntry").val();
var dataString = "kinaseEntry=" + kinaseEntry;
$("#waiting").show(500);
$("#message").hide(0);
alert(kinaseEntry);
//Fetch list from database
$.ajax({
type : "GET",
url : "post.php",
datatype: "json",
data: dataString,
success : function(datas) {
$("#message").show(500);
$("#message").html(datas);
alert(datas);
}
});
return false;
});
});
I get the following result in the address bar after the script has run;
Any help will be greatly appreciated, I am only starting to familiarize with JSON.
This is the results form testing the php file
{"kinaseSKU":"ABL1","url":"https:\/\/products.beta.invitrogen.com\/ivgn\/en\/US\/adirect\/invitrogen?cmd=catProductDetail&showAddButton=true&productID=P3049","molecularWeight":"125.4 kDa","tracerSKU":"","antiSKU1":"","antiSKU2":"","bufferSKU":"","tracerConc":"","assayConc":""}
The input form looks like;
<form id="form" action="#">
<p>To begin, start typing a Kinase:</p>
<input type="text" size="25" name="kinaseEntry" id="kinaseEntry" />
</form>
Since the problem is that you didn’t receive feedback from the action url, you may want to check your post.php. Also if you are using datatype
jsonmake sure you do the following:JQuery is strict on content type being received if you specify
jsonas the datatype