मुझे नीचे मेरी jquery स्क्रिप्ट के साथ परेशानी हो रही है, यह एक मूल छीन लिया संस्करण है और यहां तक कि यह काम नहीं करेगा, मेरे पास php फ़ाइल है जो jquery स्क्रिप्ट कॉल करता है करने के लिए, मैंने इसे एक जेसन प्रतिक्रियाएक jquery स्क्रिप्ट से चर में जेएसओएन प्रतिक्रिया कैसे प्राप्त करें
फिर jquery स्क्रिप्ट में इसे मान पढ़ना चाहिए और इसका जवाब देना चाहिए, लेकिन प्रतिक्रिया प्राप्त नहीं हो रही है।
क्या json.response json स्ट्रिंग में एक चर को कॉल करने का गलत तरीका है जो नाम प्रतिक्रिया है?
कर सकते हैं किसी को मदद कृपया मुझे
<?PHP
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json');
// set to retunr response=error
$arr = array ('resonse'=>'error','comment'=>'test comment here');
echo json_encode($arr);
?>
//the script above returns this:
{"response":"error","comment":"test comment here"}
<script type="text/javascript">
$.ajax({
type: "POST",
url: "process.php",
data: dataString,
dataType: "json",
success: function (data) {
if (json.response == 'captcha') {
alert('captcha');
} else if (json.response == 'error') {
alert('sorry there was an error');
} else if (json.response == 'success') {
alert('sucess');
};
}
})
</script>
अद्यतन अटक कर रहा हूँ;
मैं
json.response
बदल दिया है
data.response
में लेकिन यह यह ork या तो
मैंने अभी कोशिश की लेकिन यह अलग नहीं हुआ – JasonDavis
क्या आप यह जांच सकते हैं कि आपका डेटा किस प्रकार का है। 'अलर्ट (टाइपफ डेटा); सफलता कॉलबैक में इसे करना चाहिए। – RaYell
यह कहता है "ऑब्जेक्ट" – JasonDavis